Mimic Vista's Event Triggers in XP

Receive email notifications when specific events occur

Readers

September 25, 2008

2 Min Read
ITPro Today logo in a gray background | ITPro Today


Some of our customers have started migratingtheir client OSs from Windows XP toWindows Vista. They’re pretty impressed bythe Vista features that simplify their administrativeworkloads. One such feature is theEvent Viewer’s Attach Task To This Event option,which lets you create an event-triggeredaction, such as sending an email notificationwhen a specific event occurs. (To access thisoption, type Event Viewer in the Start menu’ssearch box, and click the Event Viewer iconthat appears under the Programs heading.In Event Viewer, double-click an event ID inthe Summary of Administrative Events box tobring up the Attach Task To This Event optionin the Actions pane.)

Once customers get a taste of usingevent-triggered actions in Vista, theyoften ask how they can create them onthe remaining XP workstations in theirdomains without having to use third-partysoftware. I provide them with a relativelysimple solution that uses a VBScript scriptand eventtriggers.exe, a command-lineutility included in Windows Server 2003and XP. (Eventtriggers.exe isn’t included inWindows 2000 and won’t run if you copy itto Win2K. Vista doesn’t include this utilitybecause the Attach Task to this Event featuremakes it unnecessary.)

The solution is as follows:

1. Launch Notepad and enter the scriptin Listing 1, replacing all the string valuesin double quotes with your own information.(Leave in the double quotes.) You candownload this script by going to www.windowsitpro.com, entering 99979 in theInstantDoc ID box, clicking Go, then clickingthe Download the Code Here button.
2. Save the script as Email.vbs.
3. Copy the Email.vbs script to the XPworkstation. For this example, let’s put it inthe C:utils folder.
4. On the XP workstation, launch acommand-prompt window and enter thecommand

Eventtriggers /Create  /TR "Event Triggers for All Errors"  /T ERROR /TK C:utilsemail.vbs

(Although this command appears on severallines here, you’d enter it all on one linein the command-prompt window.) In thiscommand, the /TR parameter provides thetrigger’s name (Event Triggers for All Errors),the /T parameter specifies the type of eventthat the trigger should capture (ERRORevents), and the /TK parameter identifiesthe trigger action (execute Email.vbs).

When an error appears in any log file onthat workstation, Email.vbs is executed andsends an email notification to the recipientdesignated in the script. You can fine-tunethe Eventtriggers command using its manyparameters to capture specific eventsbased on the event ID. For a list of the availableparameters, run the command

Eventtriggers /Create /?

in a command-prompt window.

—Jian Bo

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like