How can you Programmatically Map a Network Drive?

D

Dean R. Henderson

I am using VB code to create a Console application that is started on a
Windows 2003 Server via a Scheduled Task. Files are moved to and/or from a
Network Resource that I want to be setup as a Mapped Network Drive.
Currently, the application is being started with a user id based on the
Scheduled Task that allows the use of a fully qualified network name, but I
want to have the flexibility to Map the Network Drive with an alternate user
id (based on configuration data) and I am trying to find a way to
programmatically Map the Network Drive in the VB Console application.

There is a C++ Win32 function NPAddConnection that connects a local device
to a network resource that may offer a way to do this ... Does anyone have a
suggestion about how to make use of this function from a VB.NET 2005 program
(the NPAddConnection function is part of the Network Provider API functions
documented in the Windows Platform SDK).

Thanks for any suggestions/advice.

Dean
 
M

Mr. Arnold

Dean R. Henderson said:
I am using VB code to create a Console application that is started on a
Windows 2003 Server via a Scheduled Task. Files are moved to and/or from a
Network Resource that I want to be setup as a Mapped Network Drive.
Currently, the application is being started with a user id based on the
Scheduled Task that allows the use of a fully qualified network name, but I
want to have the flexibility to Map the Network Drive with an alternate
user id (based on configuration data) and I am trying to find a way to
programmatically Map the Network Drive in the VB Console application.

There is a C++ Win32 function NPAddConnection that connects a local device
to a network resource that may offer a way to do this ... Does anyone have
a suggestion about how to make use of this function from a VB.NET 2005
program (the NPAddConnection function is part of the Network Provider API
functions documented in the Windows Platform SDK).

Thanks for any suggestions/advice.
..
You use the Shell command in VB.

http://www.devx.com/dotnet/Article/7914

You Shell out and you use the Net Use command.

http://www.cae.wisc.edu/site/public/?title=nt4netuse
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top