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 


December 2004

Pulling the Event Trigger

Activate those event logs, pardner!
RSS
Subscribe to Windows IT Pro | See More Monitoring and Analysis Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Event logs are great tools for keeping track of your system. But they have one liability: You have to go look at them to see if anything important has happened. Just about every Windows administrator I know has a story about puzzling for hours over some strange system behavior and finally remembering to look in the event logs, in which the answer was evident. But suppose certain kinds of events are sufficiently important to you that you don't want to have to look at event logs to deal with them. Wouldn't it be nice to be able to configure your system to immediately and automatically respond to certain events?

You can accomplish such configuration with an event trigger. An event trigger essentially says to your system, "When this event happens, run this program." For example, suppose you're on the trail of a hacker and want to be informed every time a logon failure occurs. You could create an event trigger to use Net Send to deliver you a pop-up message or to use a program such as Blat to send you an email message from a command line. But how do you create an event trigger? You use eventtriggers.exe, which is included in Windows Server 2003 and Windows XP.

Eventtriggers.exe has a fairly complex set of parameters. The top-level parameters are /create, /delete, and /query, which let you create a trigger (triggers remain in the system until you remove them, rather than firing once and disappearing), delete a trigger, and list the triggers in the system, respectively. Simplified, the syntax for creating a trigger is

eventtriggers /create /eid <eventidnumber>
   /tr <triggername> /tk <actiontotake>

Eventidnumber is the number that tells which specific event happened—for example, 680 for an account logon, or 1054 when Group Policy can't find a domain controller (DC) to obtain your Group Policy files. Triggername is a label that identifies the trigger—you need this label to read the event trigger logs ("Which trigger did that?") or to delete a trigger. Actiontotake is the command that you want your system to execute when the particular event ID occurs—either a command-line command or the name of a batch file to run.

Before diving deeper into Eventtriggers' syntax—it has many parameters that you might find useful—let's try out an example. One event ID that's easy to generate for our testing is event ID 64002. Windows File Protection generates event ID 64002 when you delete one of the .exe, .dll, .sys, or .ocx files that ship with the OS in the \system32 directory. To demonstrate the generation of this event ID, just type

del C:\windows\system32\sol.exe

on a Windows 2003 or XP box. (If you've upgraded your system from an earlier version of Windows NT, you would use \winnt instead of \windows.) Now, when you look in the System log, you'll see event ID 64002. Next, what shall we tell the system to use as an action? If you have the Messenger service enabled on your system, you can use the Net Send command. For example, assuming your username is jack123,

net send jack123 Something's deleting system files!

would pop up a gray box on your desktop that states Something's deleting system files!

But we need one more piece: a security context. By default, Eventtriggers will run the Net Send command (or any other command) under the System account, but System can't effectively run some commands, including Net Send. So we can add two more parameters—/ru and /rp—to give Eventtriggers a user account and password to use when running Net Send. If your user account is jack123 and your password is swordfish, you could use the following command to create a new event trigger named sysalert:

eventtriggers /create /eid 64002 /tr sysalert
   /tk "net send jack123 Something's deleting system files!"
   /ru jack123 /rp swordfish

Of course, this command only informs you that the deletion is occurring. You'll have to find the miscreant to stop it.

In the space I have left, I can share a couple more useful Eventtrigger commands. To list your event triggers, type

eventtriggers /query /v

To delete all your event triggers, type

eventtrigger /delete /tid *

I'll share more Eventtriggers commands next month.

End of Article



Reader Comments
Might be handy

skarpege December 20, 2004 (Article Rating: )


The article does not go far enough. I need info on what account is doing this and how to get the trigger to push this thru the email. This wets my whistle and if I look any further I would probably have to buy some product that I do not have funds for.

rmckee January 18, 2005 (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
Microsoft: Save Money ... By Paying for Software

Microsoft this week adopted an interesting tactic in its long-running battle with open source software: Businesses looking to save money over the long haul should simply pay for software instead of moving to free, open source solutions. The rationale? ...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...

Command Prompt Tricks

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


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

Related Events How IE7 & The New Extended Validation SSL Certificates Impact Your Site

Concrete Ways to Make Sure Your SharePoint Deployment Doesn't Blow Up

Virtualization Management

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs 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