Reset IIS From VBScript#
Reset IIS if Server Does NOT Retrun 200 Status
Occasionally I have experienced a 500 server error or some other weird error in IIS when it has becomes unstable. This always seems to happen when I am not near my laptop or on the road. A simple reset of IIS always seems to do the trick, but it has always required my manual input. So, I decided to schedule a task to help with the rare occurence.

A quick search of Google did not turn up exactly what I was looking for so I wrote a quick and dirty VBScript:

On Error Resume Next
'Need a .bat file with "IISRESET" in it without quotes
ResetIIS = "c:\batches\ResetIIS.bat"
strDomain = "www.domain.com"
wscript.echo "Checking: " & strDomain
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://" & strDomain, False
xml.Send
If xml.status <> "200" Then
wscript.echo strDomain & " is throwing at server error..."
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run(ResetIIS)
Set WshShell = Nothing
Else
wscript.echo "All is well..."
End If
Set xml = Nothing


So, this VBScript is set to run every 3 minutes using the Schedule Tasks. It uses XMLHTTP to do a GET for the domain. If the status returned is not a 200 status, the batch file is kicked off to reset IIS. I added a few other things to check many domains and to also send me email and SMS alerts, but the script above is a good start for any scenario.

IIS
10/30/2005 12:08:39 AM (Eastern Standard Time, UTC-05:00) #    Comments [0]  |  Trackback

 

All content © 2008, Xfernal
On this page
This site
Calendar
<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
Scott Schecter
Entropy Expounded
Venexus DotNetNuke Blog
Articles, Code Snippits, and News from the DNN frontline.
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.1

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: