I've been trying to cut back on the amount of power we use at home. This is partly virtuous, but mainly because I've started tracking power consumption vs. generation for our solar panels (even though it's December I want to try and have a day of net generation, you can see my progress on this chart).
I bought a couple of smart strips and now have both main computers set to switch all their peripherals off when they go to sleep. This goes from 250-300 watts to 1-2 watts - very cool.
There was a problem though. I run all sorts of overnight processing - backing up databases, processing web stats, updating the webcam list for WebCamSaver - and the computer kept going to sleep in the middle of it.
Task scheduler lets you wake your computer to run a task, but there doesn't seem to be an option to stop it sleeping until the task has finished. I hunted around for a while, but it seemed like one of those times when it's just faster to write something.
Nosleep (source) is a command line tool that disables sleep or hibernate, runs a batch file or program and then enables sleep or hibernate again. It will run on any recent version of Windows - I use it from task scheduler to launch my monster batch file of overnight tasks.
It's a simple little app - it just calls SetThreadExecutionState() before and after launching the target batch file. The trick with SetThreadExecutionState is that the new state doesn't take the first time you call the function. Calling it twice has the desired effect.