This program is a VBS script. The script checks regularly that your website is live. When your site goes offline, you will receive a popup that will go away in 15 seconds. If you click OK, the popup button you will open the test page in Internet Explorer. The program will also log the error into the log file (WebsiteMonitor.vbs.log) in the same folder as the script.
To deploy this program:
- Copy Test.asp to your root folder (C:\Inetpub\wwwroot).
- Modify the first line of the WebsiteMonitor.vbs file to point it to the Test.asp on your website.
- The script has to be registered with the Windows Scheduler. Go to Control Panel > Scheduled Tasks > Add Scheduled Task. The script will run for about 24 hours, so it is important for it to be scheduled to run every day.
Using the Code
Here is the VBS script:
sURL = "http://www.MySite.com/test.asp"
For i = 1 to (24*59)
sData = GetUrlData(sURL)
If sData <> "Good" Then
Set oShell = CreateObject("WScript.Shell")
iButton = oShell.Popup ("Cannot connect to " & sURL, 15)
if iButton <> -1 Then
Log Now() & vbTab & sData
on error resume next
Set oHttp = CreateObject("MSXML2.ServerXMLHTTP")
oHttp.setTimeouts 0, 0, 0, 0
oHttp.Open "GET", sUrl, False
If oHttp.responseText = "" Then
GetUrlData = "Error Occurred : " & oHttp.Status & " - " & oHttp.statusText
GetUrlData = oHttp.responseText
Set oHttp = Nothing
Const ForAppending = 8
Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
Dim oLogFile: Set oLogFile = fso.OpenTextFile(WScript.ScriptFullName & _
".log", ForAppending, True)
On Error Resume Next
Set oShell = CreateObject("Shell.Application")
Set oIE = oShell.Windows.Item
If Err.number <> 0 Then
Set oIE = wscript.CreateObject("internetexplorer.application")
oIE.Visible = True
Set oIE = Nothing
Set oShell = Nothing
Points of Interest
I also wanted this script to beep or send an email. But I never got around doing this.
Igor is a business intelligence consultant working in Tampa, Florida. He has a BS in Finance from University of South Carolina and Masters in Information Management System from University of South Florida. He also has following professional certifications: MCSD, MCDBA, MCAD.