Option Explicit
Dim Shell, objShell, strCommand, strHost, ReturnCode, oShell
Wscript.Sleep 10000
Do
' Verify conection to internet, loop until connection established
'Host or IP to ping
strHost = "google.com"
'Create shell object
Set Shell = wscript.createObject("wscript.shell")
'What to run in command line
strCommand = "ping -n 3 -w 3000 " & strHost
'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)
'0 = pingable, 1 = no response
If ReturnCode = 0 Then
'Ping Cisco ASA in Florida
'Host or IP to ping
strHost = "vpnts.l1esd.com"
'Create shell object
Set Shell = WScript.CreateObject("WScript.Shell")
'What to run in command line
strCommand = "ping -n 3 -w 3000 " & strHost
'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)
'0 = pingable, 1 = no response
If ReturnCode = 0 Then
'If response, establish remote session to Florida ASA
'Starts IIS Cisco VPN Connect on System Boot ("C:\Program Files\Cisco Systems\VPN Client\vpnclient.exe" connect vpnts4.l1esd.com)
Set objShell = WScript.CreateObject("WScript.Shell")
strCommand = Chr(34) & "C:\Program Files\Cisco Systems\VPN Client\vpnclient.exe" & Chr(34) & " connect " & strHost
'set objexec = objshell.exec(strCommand)
ReturnCode = objShell.Run(strCommand, 0, False)
Else
'If no response Establish FAILOVER session to Illinois
'Starts FAILOVER IIS Cisco VPN Connect on System Boot ("C:\Program Files\Cisco Systems\VPN Client\vpnclient.exe" connect FAILOVER)
Set objShell = WScript.CreateObject("WScript.Shell")
strCommand = Chr(34) & "C:\Program Files\Cisco Systems\VPN Client\vpnclient.exe" & Chr(34) & " connect FAILOVER"
'set objexec = objshell.exec(strCommand)
ReturnCode = objShell.Run(strCommand, 0, False)
End If
ReturnCode = 0
Else
'wscript.echo strHost & " is Disconnected"
ReturnCode = 1
Wscript.Sleep 2000
End If
Loop Until ReturnCode = 0
'ping to verify vpn connection loop until response
Set oShell = CreateObject("Shell.Application")
Do
'Host or IP to ping
strHost = "10.165.165.35"
'Create shell object
Set Shell = wscript.createObject("wscript.shell")
'What to run in command line
strCommand = "ping -n 3 -w 3000 " & strHost
'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)
'0 = pingable, 1 = no response
If ReturnCode = 0 Then
'on response map Y: drive
Call MapDrive("Y:","\\10.165.165.35\EnrollmentData","genericlso","genericlso")
oShell.NameSpace("Y:").Self.Name = "EnrollmentData"
WScript.Quit
ReturnCode = 0
Else
ReturnCode = 1
Wscript.Sleep 2000
End If
Loop Until ReturnCode = 0
'Check Default Gateway, Map Z: Drive Accordingly
If DefaultGateway = "172.16.32.1" Then
Call MapDrive("Z:","\\172.16.32.100\fpfiles","fptech","Fptech!")
oShell.NameSpace("Z:").Self.Name = "fpfiles"
WScript.Quit
Else
Call MapDrive("Z:","\\10.165.165.200\fpfiles","fptech","Fptech!")
oShell.NameSpace("Z:").Self.Name = "fpfiles"
WScript.Quit
End If
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub MapDrive(sDrive,sShare,sUser,sPass)
On Error Resume Next
Dim WSHNetwork
Set WSHNetwork = WScript.CreateObject("WScript.Network")
WSHNetwork.RemoveNetworkDrive sDrive, 1, 1
WScript.Sleep 300
Err.Clear
WSHNetwork.MapNetworkDrive sDrive, sShare, "False", sUser, sPass
if cStr(err.number) = "-2147023677" then
msgbox err.description
end if
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function DefaultGateway
DefaultGateway = Empty
Dim oDG, oDGs, WMI
Set WMI = GetObject("winmgmts:\\.\root\cimv2")
Set oDGs = WMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each oDG In oDGs
If Not IsNull(oDG.DefaultIPGateway) Then
If Not oDG.defaultIPGateway(0) = "0.0.0.0" Then
DefaultGateway = oDG.DefaultIPGateway(0)
Exit For
End If
End If
Next
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
by: JeffPartonPosted on 2009-11-06 at 14:29:30ID: 25763639
Right after Line 70 (right before the z: mapping)
Add
Msgbox "Temporary Halt in Processing"
run the script and see if the msgbox ever pops up, if not then it doesn't get to it. Is one test.
Post back on results.