Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 2008

Mimic Vista's Event Triggers in XP

Receive email notifications when specific events occur
RSS
Subscribe to Windows IT Pro | See More Tips Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

—Jian Bo

End of Article



Reader Comments
Thanks for the article. I get the following error when I run the email.vbs script. Can someone recommend a fix? Thanks, Brian

CDO.Message.1 error '80040220' The "SendUsing" configuration value is invalid.

barn619 October 07, 2008 (Article Rating: )


Hi Brian,

I contacted Jian Bo about the error you're encountering. He recommends that you try the following code instead:

sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "<enter_mail.server_here>"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "from@me.com"
.To = "to@me.com"
.Subject = "Sample CDO Message"
.TextBody = "This is a test for CDO.message"
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing

In this code, you'll need to replace <enter_mail.server_here> with your mail server. Please let me know if this works for you.

Thanks,

Karen Bemowski, senior editor
Windows IT Pro, SQL Server Magazine

KBemowski October 08, 2008 (Article Rating: )


Would Eventtriggers monitor any log file instead of just the Windows Event logs?

squeakS October 21, 2008 (Article Rating: )


Hi Jian,

Good tool. Thanks :-)

Question: Without my testing, does anyone know if the default email program has to be running for the email to go out immediately? Or, is the message stored in the Outbox until the next time the email program runs and does a send/receive ?

Thanks,
Bret

bretabennett October 24, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
The website is down because someone removed the X-Box

What happens when a manager mistakes a server for a games console. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Microsoft Kills OneCare, Will Launch Free Security Solution

Microsoft on Tuesday announced that it would retire its $50-a-year security subscription product, Windows Live OneCare, and replace it with a free solution codenamed "Morro." Unlike OneCare, however, Morro will focus only on core anti-malware features and ...


Related Articles Windows Eventing 6.0

Fingering More Eventtriggers

Pulling the Event Trigger

Catching Events in Windows Server 2003 and Windows XP

Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing