Loop for only 10 cycles
From: stev379 (stev379_at_discussions.microsoft.com)
Date: 11/14/04
- Next message: Dave Leonardi: "Re: Remote Shutdown Batch Issue"
- Previous message: Austin M. Horst: "Re: Script to clear Cookies Temp Files Temporary Internet and History"
- Next in thread: Roger Abell [MVP]: "Re: Loop for only 10 cycles"
- Reply: Roger Abell [MVP]: "Re: Loop for only 10 cycles"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 14 Nov 2004 08:16:01 -0800
The script below works great for mapping over a VPN and uses an .htm page to
mask the users password and pull their private directory name from their
username. I'm concerned that it will get caught in a never ending loop when
it's mapping the drives if it's unable to find the drive. I've tested this
by removing the share for the first drive it's trying to map and it doesn't
error out or map anything. I'd like it to loop X (10 if possible) amount of
times before moving on if it can't find the drive. Any suggestions on how
to prevent the loop from going more than 10 cycles?
Any help or suggestions are greatly appreciated!
Thanks!
-Steve
'Begin Script
'****ENTER USERNAME AND PASSWORD****
'Option Explicit
On Error Resume Next
Dim strComputer, IE, path, UsrNm, fso, password,_
Drive1, Drive2, Drive3, intCounter
path = WScript.ScriptFullName
path = Left(path, InstrRev(path, "\"))
intCounter = 1
Set IE = WScript.CreateObject("InternetExplorer.Application")
IE.left=0 'Line 10
IE.top = 50
IE.height = 308
IE.width = 651
IE.menubar = 0
IE.toolbar = 0
IE.statusbar = 0
IE.resizable = 1
IE.navigate path + "WebIn2VB.htm"
IE.visible = 1
Do While (IE.Document.All.OKClicked.Value = "")
If err <> 0 Then
Msgbox "Name and Password not entered. "_
& "Network Drives have not been mapped."
Set IE = Nothing
WScript.Quit
Else
WScript.Sleep 250
End If
Loop
' Line 30
UsrNm = IE.Document.All.UsrNm.Value
password = IE.Document.All.PasswordBox.Value
IE.Quit
Set IE = Nothing
Wscript.Sleep 5000
'****BEGIN DRIVE MAPPING****
strMyName = UsrNm
strMyPwd = password
Dim WSHNetwork, objNet
Set WSHNetwork = WScript.CreateObject("WScript.Network")
'strMyName is pulled from UsrNm
strMap2 = "DATA"
strMap3 = "SDP"
strDrv1 = "\\SERVER\" & strMyName
strDrv2 = "\\SERVER\" & strMap2
strDrv3 = "\\SERVER\" & strMap3 'Line 50
StrNet = "DOMAIN\" & strMyName
Drive1 = "P"
Drive2 = "Q"
Drive3 = "R"
Set fso = CreateObject("Scripting.FileSystemObject")
Do Until fso.DriveExists(Drive1)
WSHNetwork.MapNetworkDrive "P:", strDrv1,"false", strNet, strMyPwd
If fso.DriveExists(Drive1) Then Exit Do
Loop
Do Until fso.DriveExists(Drive2)
WSHNetwork.MapNetworkDrive "Q:", strDrv2, "false", strNet, strMyPwd
If fso.DriveExists(Drive2) Then Exit Do
Loop
Do Until fso.DriveExists(Drive3)
WSHNetwork.MapNetworkDrive "R:", strDrv3,"false", strNet, strMyPwd
If fso.DriveExists(Drive3) Then Exit Do
Loop
'****CHECKS IF ALL DRIVES ARE MAPPED AND RETURNS MESSAGE IF NOT****
Dim WshShell, Result
'Wscript.Sleep 5000
On Error Resume Next
set WshShell = CreateObject("WScript.Shell")
If fso.DriveExists(Drive1) Then
QDRIVE
Else
Wscript.Echo "P: drive mapping failed"
QDRIVE
End If
Sub QDRIVE
If fso.DriveExists(Drive2) Then
RDRIVE
Else
Wscript.Echo "Q: drive mapping failed"
RDRIVE
End If
End Sub
Sub RDRIVE
If fso.DriveExists(Drive3) Then
DONE
Else
Wscript.Echo "R: drive mapping failed"
Wscript.quit
End If
End Sub
Sub DONE
Wscript.sleep 2000
Result = WshShell.Popup("Your Mapped drives are now"_
&" available.", 5,"ASHP Mid-Year Drive Mapping", 0 + 48)
End Sub
'End Script
- Next message: Dave Leonardi: "Re: Remote Shutdown Batch Issue"
- Previous message: Austin M. Horst: "Re: Script to clear Cookies Temp Files Temporary Internet and History"
- Next in thread: Roger Abell [MVP]: "Re: Loop for only 10 cycles"
- Reply: Roger Abell [MVP]: "Re: Loop for only 10 cycles"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|