:PING
ping -n 1 -w 50 192.168.11.1 > nul
if errorlevel 1 goto PING
ping -n 1 -w 50 192.168.11.1 > nul
if errorlevel 1 goto PING
Is there a way to tell if a server is up with a .vbs file? Yes! I'm using a modified version of this to return a 1 or a 0 for MRTG trending.
On Error Resume Next
strTarget = "10.123.30.12" 'IP address or hostname
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 1 -w 50 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
'WScript.Echo strPingResults
if err.number > 0 then
WScript.Echo "ERROR"
End If
If InStr(strPingResults, "reply from " & strTarget) Then
WScript.Echo strTarget & " responded to ping."
Else
WScript.Echo strTarget & " did not respond to ping."
End If
No comments:
Post a Comment