In my quick research, by no means exhaustive, I found three ways of doing this under Windows:
- If you're (un)lucky enough to run Vista, you can set up a Task Scheduler job that reacts to a System Event
- Alternatively, you can install a Windows utility whose exact purpose in life is to run stuff whenever you suspend or resume the system.
- You can write a simple tool, service, or Windows script to respond to and process the Windows power events, and do whatever you need to to.
In my case, the machine is running Vista so I first explored option 1. For my needs, it works very well. Under Vista only (as far as I can tell this is not possible under earlier versions of Windows) here are the steps to create a Task Scheduler entry to run when the system resumes:
- Run "TASKSCHD.MSC" to bring up the Task Scheduler
- From the Task Scheduler Library actions choose "Create Task"
- Fill in the General information as needed
- Under Triggers, choose New and Begin the task "On an event"
- Set basic settings Log:System, Source:Power-Troubleshooter and Event ID:1
- Click OK and go to Actions
- Set Action:Start a program, and enter the location of your script/tool
- Review the Conditions and Settings tabs and adjust as needed
Once this is done, save the task and test it by choosing "Run" with the item selected. Once this is working, test it by suspending then resuming your system, it should work!
Another alternative for all versions of Windows is Hibernate Trigger. It is a simple tool that is easy to install and configure, and doesn't require any additional information here really. Basically:
- Create your script, e.g. C:\WAKEUP.BAT
- Install and run Hibernate Trigger
- Configure it to run C:\WAKEUP.BAT on Resume
- Old-school WIN32 programmers can process the WM_POWERBROADCAST Message (include SERVICE_ACCEPT_POWEREVENT if writing a service)
- You can also look into processing the Win32_PowerManagementEvent triggers in scripts
So those are a few solutions to meet the need of running tasks after system sleep. Most people don't need to do thise, but those that do it's a good trick to know.