• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

How do I connect to mapped drive asking for login / password in VB

Have a mapped drive on a windows 2003 server.  It is a secure drive requiring a login and password to access (mapped to an AS400 and loses connectivity after the weekend IPL).

I have some VB code that needs to get files from this mapped folder.  I can manually double-click on folder and enter login and password.  The drive will then be available until the next IPL.
Can someone show the vb code to connect the drive after a Try/Catch fails using a
Directory.SetCurrentDirectory(FolderX)?
0
NMHGADM
Asked:
NMHGADM
  • 3
  • 3
  • 2
1 Solution
 
arnoldCommented:
as part of the connection you need to provide credentials,

Which method are you using to map/access the drive?  Net use or are you relying on the existance of the mapped drive when you run the script?
0
 
NMHGADMAuthor Commented:
I am relying on the existance of the mapped drive.  
0
 
arnoldCommented:
The problem is that you can not be sure that the mapped drive is there, or that the mapped drive is mapped with the correct credentials.
If you catch an error because the mapped drive is not present, the option is to map the drive with the credentials with which the VB application is running.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
RobSampsonCommented:
Holy moly!!!  No "map network drive" in VB.NET?  That's surprising....anyway, I found this:
http://cjwdev.wordpress.com/2010/05/30/map-network-drive/

In VBScript, it's as simple as this:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\server\share", False, "domain\username", "password"

Regards,

Rob.
0
 
RobSampsonCommented:
BTW, VBScript doesn't support a Try Catch method....that's .NET....
0
 
NMHGADMAuthor Commented:
Thanks Rob - since I am very very new at VB.net I will have someone review with me the link you provided and let you know.
0
 
NMHGADMAuthor Commented:
Thax Rob were were able to make this work and tested fine
0
 
RobSampsonCommented:
Great. Thanks for the grade.

Rob.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now