Code: Select all
' Script to check site is running and if not restart service
Dim objShell
Dim strWebsite
Dim strIPaddress
Dim strPortnum
' ### Change to your IP address ###
strIPaddress = "192.168.0.120"
' ### Change to your Port number ###
strPortnum = "443"
strWebsite = strIPaddress & ":" & strPortnum & "/sabnzbd"
If PingSite( strWebsite ) Then
'
' ### Put this here to enable you to check script is running, just comment
' ### it out once its up and running.
' WScript.Echo "Web site " & strWebsite & " is up and running!"
Else
set objShell = wscript.createObject("wscript.shell")
strTmp = "Net stop SABnzbd"
objShell.Run strTmp
strTmp1 = "Net Start SABnzbd"
objShell.Run strTmp1
End If
Function PingSite( myWebsite )
Dim intStatus, objHTTP
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", "http://" & myWebsite & "/", False
objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"
On Error Resume Next
objHTTP.Send
intStatus = objHTTP.Status
On Error Goto 0
If intStatus = 200 Then
PingSite = True
Else
PingSite = False
End If
Set objHTTP = Nothing
End Function