Reputation: 13
I need to come up with simple solution for an internet gw in SOHO environment. It has 2 internet connections - main via adsl link and backup via USB 3G modem. Both connections export standard PPP interface, so them can easily be switched on/off via command line or scripts. Script has to be able:
Any suggestions and useful code snippets/fragments I can borrow, to make these task easier?
Upvotes: 1
Views: 2542
Reputation: 42192
With the following script you can check is a connection is up, add a few sleeps and loops and you are good.
Function ExecPing(strTarget)
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
WScript.Echo VbCrLf & strTarget & " responded to ping."
ExecPing = True
Else
WScript.Echo VbCrLf & strTarget & " did not respond to ping."
ExecPing = False
End If
End Function
ExecPing inputbox( "Give the ip/unc/url to ping:")
Upvotes: 2