Windows 7 – How to Execute a Program on Power Events

batterylaptoppower-managementwindows 7

I'm basically looking for a way to execute an application when my laptop transitions to battery power and, similarly, when it returns to AC.

Is there a built-in hook in Windows or a third-party application that will allow me to respond to such events?

EDIT

I've looked into the TaskScheduler trying to fire off a task on a "power" event, but no event seems to be logged when switching to battery.

Best Answer

I wrote an application (http://batterysaver.codeplex.com/) that will listen for a power mode change message and execute actions based on an XML configuration.

If someone else can use it, or extend it, then awesome. If there's something better, then please post it.

Related Question