Click here to Skip to main content
11,932,103 members (55,576 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked

Website Monitor

, 21 Apr 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
This program is a VBS script that checks your website every minute and warns you when it goes offline.


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:

  1. Copy Test.asp to your root folder (C:\Inetpub\wwwroot).
  2. Modify the first line of the WebsiteMonitor.vbs file to point it to the Test.asp on your website.
  3. 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 = ""

For i = 1 to (24*59) 'minutes in day
    sData = GetUrlData(sURL)
    If sData <> "Good" Then
        Set oShell = CreateObject("WScript.Shell")
        iButton = oShell.Popup ("Cannot connect to " & sURL, 15)
        if iButton <> -1 Then
            OpenIE sURL
        End If
        Log Now() & vbTab & sData
    End If

    WScript.Sleep(1000*60) '1 minute

Function GetUrlData(sUrl)
    on error resume next
    Dim oHttp
    'Set oHttp = CreateObject("Microsoft.XMLHTTP")
    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
    End If
    Set oHttp = Nothing
End Function

Sub Log(sLine)
    Const ForAppending = 8
    Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
    Dim oLogFile: Set oLogFile = fso.OpenTextFile(WScript.ScriptFullName & _
                                 ".log", ForAppending, True)
    oLogFile.WriteLine sLine
End Sub

Sub OpenIE(sURL)
    On Error Resume Next
    Set oShell = CreateObject("Shell.Application")
    Set oIE = oShell.Windows.Item

    oIE.Navigate2 sURL
    If Err.number <> 0 Then
        Set oIE = wscript.CreateObject("internetexplorer.application")
        oIE.Visible = True
        oIE.Navigate2 sURL
    End If
    Set oIE = Nothing
    Set oShell = Nothing
End Sub

Points of Interest

I also wanted this script to beep or send an email. But I never got around doing this.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Igor Krupitsky
Web Developer
United States United States
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.

You may also be interested in...

Comments and Discussions

QuestionQuestion Pin
Rovy b4-Sep-12 19:16
memberRovy b4-Sep-12 19:16 
GeneralPretty OK Pin
TommyTooth21-Apr-10 21:12
memberTommyTooth21-Apr-10 21:12 
GeneralRe: Pretty OK Pin
Igor Krupitsky21-Apr-10 22:15
memberIgor Krupitsky21-Apr-10 22:15 
VB script files are transparent and are easy to modify. They are perfect for programs that are simple and don’t need UI.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 21 Apr 2010
Article Copyright 2010 by Igor Krupitsky
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid