Link to home
Start Free TrialLog in
Avatar of techindahaus
techindahaus

asked on

Reboot server if connection fails

I'm looking for an application that will allow me to have a windows server reboot if it cannot ping a specific ip or URL after a predesignated amount of time AND on a schedule of my choosing. What's available?
Avatar of Kimputer
Kimputer

It sounds simple enough for a script (VBscript/Powershell), or even a program written in a free version of Visual Express would do.

Here's a very simple VBscript to start with:

On Error Resume Next

Dim strTarget, strPingResults
strTarget = "10.0.1.11" 'IP address or hostname

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping -n 3 -w 2000 " & strTarget) 'send 3 echo requests, waiting 2secs each
strPingResults = LCase(WshExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
'	WScript.Echo strTarget & " responded to ping."  

Else
'	WScript.Echo strTarget & " did not respond to ping."
	Set WshExec = WshShell.Exec("shutdown /r /t 1") 'reboot within 1 second
End If

Open in new window


More logic and programming can be added if it's too simple. You can just schedule this as many times as you want.
ASKER CERTIFIED SOLUTION
Avatar of techindahaus
techindahaus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, that's basically the same. What feature is now lacking that you need a program to do it? Scheduled tasks controls the schedule, I don't see what other features you need?
Avatar of techindahaus

ASKER

I was looking for an application but settled for two scripts to do the same job.