' This script will ping a server 3 times with a 5 minute wait inbetween.
' If it fails, it will re-start the PC it is running on.
' It needs to have Admin access on the PC.
pingtimes = 0
pingserver = "Failed";
DBipaddress = "" ' Set the server IP address
Do While (pingserver = "Failed" and pingtimes <= 2)
if pingtimes > 0 then WScript.Sleep(300000)
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = WshShell.run("ping -n 1 " & DBipaddress, 0, True)
If PINGFlag = 0 Then
pingserver = "OK"
Else
pingserver = "Failed"
End If
pingtimes = pingtimes + 1
Loop
if pingserver = "Failed" then
Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
end if
VBScript to ping a server and restart on fail
(1 post) (1 voice)-
Posted 1 year ago #
Reply
You must log in to post.