Some of our customers have started migrating their client OSs from Windows XP to Windows Vista. They’re pretty impressed by the Vista features that simplify their administrative workloads. One such feature is the Event Viewer’s Attach Task To This Event option, which lets you create an event-triggered action, such as sending an email notification when a specific event occurs. (To access this option, type Event Viewer in the Start menu’s search box, and click the Event Viewer icon that appears under the Programs heading. In Event Viewer, double-click an event ID in the Summary of Administrative Events box to bring up the Attach Task To This Event option in the Actions pane.)
Once customers get a taste of using event-triggered actions in Vista, they often ask how they can create them on the remaining XP workstations in their domains without having to use third-party software. I provide them with a relatively simple solution that uses a VBScript script and eventtriggers.exe, a command-line utility included in Windows Server 2003 and XP. (Eventtriggers.exe isn’t included in Windows 2000 and won’t run if you copy it to Win2K. Vista doesn’t include this utility because the Attach Task to this Event feature makes it unnecessary.)
The solution is as follows:
1. Launch Notepad and enter the script
in Listing 1, replacing all the string values
in double quotes with your own information.
(Leave in the double quotes.) You can
download this script by going to www.windowsitpro.com, entering 99979 in the
InstantDoc ID box, clicking Go, then clicking
the Download the Code Here button.
2. Save the script as Email.vbs.
3. Copy the Email.vbs script to the XP workstation. For this example, let’s put it in the C:\utils folder.
4. On the XP workstation, launch a command-prompt window and enter the command
Eventtriggers /Create /TR "Event Triggers for All Errors" /T ERROR /TK C:\utils\email.vbs(Although this command appears on several lines here, you’d enter it all on one line in the command-prompt window.) In this command, the /TR parameter provides the trigger’s name (Event Triggers for All Errors), the /T parameter specifies the type of event that the trigger should capture (ERROR events), and the /TK parameter identifies the trigger action (execute Email.vbs).
When an error appears in any log file on that workstation, Email.vbs is executed and sends an email notification to the recipient designated in the script. You can fine-tune the Eventtriggers command using its many parameters to capture specific events based on the event ID. For a list of the available parameters, run the command
Eventtriggers /Create /?in a command-prompt window.