Click here to Skip to main content
15,559,642 members
Articles / Programming Languages / VBScript
Posted 1 May 2003


55 bookmarked

SSMonitor - Monitor a Visual SourceSafe database using VBScript

Rate me:
Please Sign up or sign in to vote.
5.00/5 (24 votes)
1 May 20039 min read
A VBScript utility that continually monitors a VSS database and sends emails when certain patterns are detected. Can be run as an NT service.

Introduction to SSMonitor

SSMonitor is a free Windows Scripting utility written to monitor the activity in a Visual SourceSafe journal file. Various event pattern filters can be defined, and email messages can be sent to notify developers when these events occur.

We use SSMonitor to email summary reports of VSS activity every day, and to broadcast significant events (like file deletions or project build setting changes) to all developers. IMHO, these are features that VSS should have had from day one, but don’t get me started. :-)

SSMonitor is designed to be run in a console window on any machine with access to the SourceSafe journal file. No VSS automation component is used, and no VSS license is required. SSMonitor can be run as an NT service.

The first half of this article describes how to install and use SSMonitor, and the second half describes some the VBScript code used to implement SSMonitor.

Part 1 - Installing and using SSMonitor

SSMonitor Features

  • Monitors a VSS journal file for user-defined event patterns and sends email notification when events are detected.
  • Email can be sent as plain text (ugly) or HTML (less-ugly, big-boned maybe?).
  • Events can be filtered by VSS activity (ie. Check ins, moves, etc) and/or by project patterns (ie. "*.cpp" or "\myproject\folder")
  • Events can have a report period, to allow multiple similar events to be reported in a single email. This helps cut down on the noise generated by the script.
  • Each event definition can have its own destination email addresses if required.
  • All of SSMonitor’s configuration data comes from an XML file, which SSMonitor will also monitor while running. If you make changes to the XML file while SSMonitor is running, any cached events are sent out, and the new XML configuration is loaded. No need to shutdown/restart SSMonitor just because you changed a configuration parameter.
  • Running SSMonitor.wsf with no command line arguments (cscript.exe SSMonitor.wsf) gives a great big help page. Most of what you need to get going should be found there.
  • Adminstrator emails will be sent when certain "significant" events happen:
    • When SSMonitor starts or stops.
    • When SSMonitor reloads its configuration file because it has detected a change.
    • When SSMonitor loses or regains access to the VSS journal file
  • SSMonitor can be run as an NT service using the free SRVANY.EXE and INSTSRV.EXE tools from the Windows Resource Kit


  • Windows Scripting Host 5.6 or later. Tested on Win2K Pro SP3 and XP Pro SP1. If you’re running Win2K or XP, WSH 5.6 is likely already installed.
  • Access to a Visual SourceSafe database’s journal file. Your VSS database must be configured to log all activity to a journal file. This is set in the Journal_File= setting of srcsafe.ini. See the VSS documentation for details.
  • SSMonitor uses the freeware SMTP control from Ostrosoft, available here. Thanks OstroSoft!


  1. Unzip the archive to a folder. This article assumes the archive is extracted to C:\Program Files\SSMonitor
  2. Configure the appropriate parameters in an XML file. You can use the supplied config.xml as a template.
  3. To install SMTP.ocx, follow the OstroSoft instructions (reproduced here as a convienience):
    1. download
    2. unzip SMTP.ocx from it to Windows System directory
    3. run "regsvr32 SMTP.ocx" from command-line

Running SSMonitor as a console app

Just run the script using the console script engine. Make sure you supply the /ConfigFile:yourConfigFile.xml argument. If you don’t, don’t worry, the script will nag at you (and nag, and nag) for all the right parameters. The following command should do the trick.

cscript.exe "C:\Program Files\SSMonitor\SSMonitor.wsf" <BR>            /ConfigFile:"C:\Program Files\SSMonitor\config.xml"

Running SSMonitor as an NT service

I recommend running SSMonitor as an NT service, but only after you've debugged its configuration and deployment at your site, while running SSMonitor as a console app from an interactive logon account. While SSMonitor does provide a fair bit of notification via email, if your SMTP email configuration has not been tested you'll have no available feedback that the service is misconfigured.

SSMonitor can be run as an NT service (and this is how our team has it currently deployed). The free Windows Resource Kit from Microsoft includes two useful tools to easily enable any console application to run as a service. Unfortunately, the documentation that comes with the Resource Kit for INSTSRV and SRVANY is a bit sparse.

Here is what you need to do:

  • Assumption: The archive is extracted to C:\Program Files\SSMonitor
  • Assumption: The cscript.exe tool is installed at C:\WINDOWS\system32\cscript.exe
  • Assumption: The INSTSRV.EXE and SRVANY.EXE tools are installed at C:\Program Files\Windows Resource Kits\Tools
  • Install the SRVVANY program as a service named SSMonitor
    instsrv SSMonitor "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"
  • Use REGEDIT to add the startup parameters for SRVANY. This is part that Microsoft forgot to document!

    There are 3 registry keys that need to be added as follows:

    "AppParameters"="C:\\Program Files\\SSMonitor\\SSMonitor.wsf <BR>              /ConfigFile:C:\\Program Files\\SSMonitor\\config.xml"
    "AppDirectory"="C:\\Program Files\\SSMonitor"

Example configuration XML

The example XML file below is the sanitized version of the XML configuration I run on our VSS database. I’ve changed the names of a few servers and email addresses, but otherwise it is verbatim.

This configuration monitors the journal file for three types of events patterns:

  • Detect deleted files - Event pattern that watches for any file delete/destroy/purge operations and reports them after 5 minutes. This pattern is useful to warn other developers that their local working folders are now out of date and require a manual fix (ie. The other developers have to go and manually delete the file(s) that were just toasted).
  • Build settings - Event pattern that looks for changes to DevStudio .DSP and .DSW files. Again, this pattern helps give other developers a "heads up" that their next build might not work unless they do a fresh get.
  • Daily activity report - Event pattern that runs once a day and sends out a list of what changed in the past 24 hours.

Things to note:

  • Email headers and footers can span multiple lines. This allows you to format your emails nicely.
  • Common email options are specified in the <smtp> node. These settings are the defaults for any patterns, but any pattern can override the defaults if required.
  • The message body of the email will always be: <smtp.emailHeader> + <pattern.emailHeader> + all matching events + <pattern.emailFooter> + <smtp.emailFooter>. This format allows the greatest flexibility.
  • HTML formatted emails can contain HTML tags in the header & footer, but I haven’t tested that too much.
<?xml version="1.0" ?>
    <!-- UNC path to VSS database journal file -->
    <!-- SMTP server properties -->
        emailDest=",,_<BR>        "
        emailFooter="If this email is annoying you, see the adminstrator.

No animals were harmed during the automatic formatting of this message."

    <!-- List of VSS event patterns to monitor -->
            name="Detect deleted files"
            emailSubject="WARNING: Stale working folders"
            emailHeader="<BR>Warning: Critical SourceSafe operations were performed that may <BR>leave your working folders out of date!

Check your working folders to ensure that no stale copies remain.

You have been warned! 

The following files were removed or relocated:"
            name="Build settings"
            eventFilter="Checked In"
            emailSubject="Build change settings detected"
            emailHeader="Change in build settings detected. Your " &_<BR>                        "mileage may vary."
            name="Daily activity"
            emailSubject="Daily activity report"
            emailHeader="The following SourceSafe changes were detected "&_<BR>                        "during the past 24 hours."
            fixedReportTime="9:00 PM"

Part 2 - Understanding the SSMonitor code


I wrote SSMonitor because I was mad. Sort of.

I had started work on a multi-site project, with a development team in Boston, and another development team in Vancouver. Because of the geographic separation, our combined team needed some sort of notification tool to let other developers know about important changes to the codebase. I found a pay-ware product on the 'net, and it does everything SSMonitor does, but their pricing was outrageous. For our combined team of 30 developers, they wanted about $2500 for this feature. I couldn't believe it. Their product manager tried to sell me on "all their hours of VSS expertise and the stability of their product" but I just said "Bollocks! I can write something like that in a few hours". I hung up the phone, and about two hours later, I began writing SSMonitor during a 6-hour flight from Boston to Vancouver.

When the plane landed, I had learned enough VBScript to write code could monitor and parse the VSS journal file, and by the next day I had SSMonitor sending emails out the entire team. Did it take more than "a few hours" to write? Of course! I'm a programmer! Did you actually believe my first estimate? Maybe I could have finished the whole project on the flight if the AirBus 320 had a WiFi network and an SMTP server :-) But it still took less time than the $2500 price tag of the pay-ware product, so the economics still made sense. Plus, I now have a reason to post something useful to CodeProject, after years of being a happy CodeProject consumer!

Learning VBScript and Windows Scripting Host

I'm a C++ diehard, but I had done a bit of VB here and there. Sometimes I've even been paid to do it! I had already started using VBScript while setting up the daily build using the excellent VisualBuild Pro tool from Kinook Software. I was pretty sure that I could toss together a VBScript snippet to parse the VSS log file.

I've found VBScript to be a pretty cool power tool, allowing me to create classes of objects much like C++. As SSMonitor was my first significant VBScript project, I'm sure that the code will have a C++ flavour to it. Dunno if that is good or bad. :-)

Visual SourceSafe Journal File Format

Visual SourceSafe can be configured to maintain a journal file of all activity performed on the database. This feature is enabled by setting the Journal_File=myjournalfile.log setting in the database's SrcSafe.ini file.

After each action performed by a VSS client, the client will also append a simple text description of the action to the journal file. Each entry has the following format:

Version: x
User: VssAccountName   Date: mm/dd/yy  Time: hh:mm[ap]
Comment: Comment text
Further comment text follows on subsequent lines
(ends with blank line)

Writing a parser for this simple text format was pretty straight forward, and is handled by the SSMON_CVssJournalParser.Parse( in_strFileName, in_nByteOffset ) method.

Main Monitoring Loop

The main loop for SSMonitor is pretty simple.

  • Load all the patterns and parameters from the XML config file. Sub SSMON_LoadConfigFile( ByVal in_strFilename )
  • Monitor the databaseSub SSMON_MonitorDb
  • Get the current file size of the journal file. Function SSMON_GetFileSize( ByVal in_strFilename )
  • Check if the journal file has changed size. If so:
  • Parse all the newly added records from the journal file. Sub SSMON_CVssJournalParser.Parse( in_strFileName, in_nByteOffset )
  • Compare each newly parsed record against the array of patterns. Any pattern that matches the record caches the record for later emailing.Sub SSMON_CVssJournalParser.ProcessEvent
  • Sleep for little while.
  • Check all the patterns to see if their time-to-email has expired. Send out any emails as necessary. Sub SSMON_CMonitorPattern.FlushCacheIfExpired( in_smtpServer )
  • Lather, rinse, repeat.


2002-Sep-01 Initial release (posted elsewhere on the 'net).

2003-May-02 First posting on CodeProject. Now supports fixed time-of-day emails, administrator emails, and multi-format date strings.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Web Developer
Canada Canada
When not riding roller coasters, Doug Schmidt is a developer based in Vancouver, Canada.
He is not the Doug Schmidt, PhD who contributes to the "C++ Report", nor is he the avant garde accordian player Doug Schmidt, nor is he Douglas Schmidt the classical composer. However, he once almost shared a limo with Arnold Schwarzenegger.

Comments and Discussions

QuestionAutomatically refresh Solution Explorer source control status icon ? Pin
Alexandru Matei3-Oct-09 22:57
Alexandru Matei3-Oct-09 22:57 
GeneralThis is a beautiful piece of software Pin
Member 470466511-Dec-07 2:25
Member 470466511-Dec-07 2:25 
GeneralCheckOut changes Pin
glenn_goodwin828-Jul-07 20:35
glenn_goodwin828-Jul-07 20:35 
GeneralImpressive Pin
gregsohl18-Jul-07 11:08
gregsohl18-Jul-07 11:08 
QuestionWhere i have to get the cscript.exe, SRVANY.EXE & INSTSRV.EXE ? Pin
Saranay31-May-07 6:12
Saranay31-May-07 6:12 
QuestionSame Idea as Visual SourceSafe Journal Monitor? Pin
kckriegs2-May-07 17:17
kckriegs2-May-07 17:17 
GeneralDoesnt work when installed as service.. workes with console.. Pin
akumaramadas24-Jan-07 4:47
akumaramadas24-Jan-07 4:47 
GeneralRe: Doesnt work when installed as service.. workes with console.. Pin
akumaramadas24-Jan-07 4:51
akumaramadas24-Jan-07 4:51 
QuestionEmail problems when running as an NT service. Pin
mr_nishantpant24-Aug-06 4:52
mr_nishantpant24-Aug-06 4:52 
QuestionRe: Email problems when running as an NT service. Pin
akumaramadas24-Jan-07 4:44
akumaramadas24-Jan-07 4:44 
QuestionRe: Email problems when running as an NT service. Pin
akumaramadas31-Jan-07 22:13
akumaramadas31-Jan-07 22:13 
Questionconvert to c# Pin
simmik3-Aug-06 5:26
simmik3-Aug-06 5:26 
GeneralError running cscript.exe Pin
seema_bhat8-May-06 3:37
seema_bhat8-May-06 3:37 
GeneralRe: Error running cscript.exe Pin
mr_nishantpant24-Aug-06 5:08
mr_nishantpant24-Aug-06 5:08 
Generalredirect output to a file and modifications Pin
Toto le rigolo23-Jan-06 2:51
Toto le rigolo23-Jan-06 2:51 
GeneralRe: redirect output to a file and modifications Pin
Beej12613-Oct-06 9:04
Beej12613-Oct-06 9:04 
Generalerrors (0x80040E57) and ADODB.Command error '800a0d5d' Pin
edwardel16-Nov-05 8:46
edwardel16-Nov-05 8:46 
GeneralOSSMTP Pin
Kudos3-Nov-05 13:46
Kudos3-Nov-05 13:46 
GeneralSSMonitor in spanish Pin
Member 23297826-Oct-05 7:39
Member 23297826-Oct-05 7:39 
GeneralRe: SSMonitor in spanish Pin
Martin Wittershagen3-Feb-06 4:05
Martin Wittershagen3-Feb-06 4:05 
GeneralExternal Caching Pin
dootndo226-Jul-05 17:39
dootndo226-Jul-05 17:39 
GeneralDaily Builds - Build Manager Pin
Anonymous27-Jun-05 5:56
Anonymous27-Jun-05 5:56 
GeneralPatch for SSMonitor.wsf date parsing bug Pin
ol' boy hank3-Feb-05 15:37
ol' boy hank3-Feb-05 15:37 
GeneralRe: Patch for SSMonitor.wsf date parsing bug Pin
ol' boy hank3-Feb-05 15:39
ol' boy hank3-Feb-05 15:39 
GeneralThank you ... Pin
sworley24-Nov-04 7:09
sworley24-Nov-04 7:09 

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.