Login | |
|
 |
RE: Error Handling with objNetwork - 6/20/2008 3:04:15 AM
|
|
 |
|
| |
dm_4ever
Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
You would have to put On Error Resume Next before you try mapping the drive...then if Err.Number <> 0 re-prompt and On Error Goto 0. Maybe put the prompt to get the info into a Sub or Function to make it re-calling it easier.
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Error Handling with objNetwork - 6/20/2008 5:54:08 AM
|
|
 |
|
| |
GreatBarrier86
Posts: 71
Score: 0
Joined: 3/10/2008
Status: offline
|
Set objNetwork = CreateObject("WScript.Network") WScript.Echo "Enter Your Network Credentials" WScript.StdOut.Write "Username: " strUsername = WScript.StdIn.ReadLine WScript.StdOut.Write "Password: " strPassword = WScript.StdIn.ReadLine On Error Resume Next objNetwork.MapNetworkDrive "I:", "my server",, strDomain & "\" & strUsername, strPassword Do While Err = -2147023677 Err.Clear WScript.Echo WScript.Echo "Username or Password Incorrect - Please Re-Enter Credentials" WScript.StdOut.Write "Username: " strUsername = WScript.StdIn.ReadLine WScript.StdOut.Write "Password: " strPassword = WScript.StdIn.ReadLine objNetwork.MapNetworkDrive "I:", "my server",, strDomain & "\" & strUsername, strPassword Loop That's what i did. Notice the Err.Clear. for some reason, unless it is clear, the next mapping won't update the error code.
|
|
| |
|
|
|
|
|