Trigger happy events

The new Task Scheduler functionality that was introduced with Windows Vista is superb, it knocks spots off what Windows XP ever had; my favourite feature is the ability to fire a task if a certain event is logged in the Windows Eventlog, which is great because it opens up all sorts of possibilities.

A while ago I had a dodgy ADSL router at home which would periodically reset itself but I was never able to understand why.  Upon reset, it would refuse to respond to my Windows XP computer until I manually did a "ipconfig /renew" from my computer.  Also, an error was logged in the Windows Eventlog when the client computer attempted to use the network but discovers that it had lost network access.  While I was at home, this was never an issue but if I was away from home, and I wanted to use RDP to connect to my home computer, then it proved frustrating because I could not get access.  As a workaround, I wrote a VB script that periodically pinged the router and if router did not respond it would run the "ipconfig /renew" command itself.  Not a very graceful fix but it did the trick.

Now, had I had Windows Vista at the time, then I could have created a task that looked for the Windows event that was caused by the router resetting itself.  Then, when the event appears, I could have launched a script that renewed the IP address.  That would have been far simpler and it would have used built-in functionality rather than some homegrown solution.

An example of the Windows Vista trigger window is included below.  As you can see, you can create a trigger for pretty much any event, in any log.


Anyway, I actually wanted to blog about Windows XP here because with the use of a tool from the resource kit you can create this exact same functionality for Windows XP!  If only I had known when I was having the fun and games with my ADSL router...

There is a tool called eventtriggers.exe that allows you to trigger an action when an event is logged (perhaps that is why they called it eventtriggers.exe???)  This is useful in plenty of scenarios, not just the one I described earlier.  For example, the command below will launch Windows Backup when a low disk space warning is logged.  The event will trigger a script to be launched that automatically runs a disk cleanup.

eventtriggers /create /s srvmain /u contoso\jbloggs /p p@ssW23 /tr "Low Disk Space" /eid 4133 /t warning /tk \\server\share\diskcleanup.cmd

Here are full details of all the switches for the command line:

And here is some more information about the tool: