Link to home
Start Free TrialLog in
Avatar of NMHGADM
NMHGADMFlag for United States of America

asked on

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)?
Avatar of arnold
arnold
Flag of United States of America image

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?
Avatar of NMHGADM

ASKER

I am relying on the existance of the mapped drive.  
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.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW, VBScript doesn't support a Try Catch method....that's .NET....
Avatar of NMHGADM

ASKER

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.
Avatar of NMHGADM

ASKER

Thax Rob were were able to make this work and tested fine
Great. Thanks for the grade.

Rob.