Question: I have created scheduled tasks on both a Vista and Win7 machine which wake up the machine if it is currently in a sleep state. However, if the task takes longer than the power settings are configured on the machine, the machine will return to a sleep state. It looks like [this](http://www.catfood.net/blog/2008/12/prevent-sleep-during-scheduled-tasks.asp) utility might be a solution, but I was wondering if there were other options.

Does anyone know of a powershell command or other utility that will prevent my machine from going into a sleep state while a task is running?

Answer: 
There is a setting in Scheduled Tasks that you can check or uncheck which will cause a task or script to exit if it runs longer than the time specified by the checked setting. For example, if you have a task which wakes up your computer at 4 AM to do windows updates, virus scans, etc, the task will not finish if it takes longer than the time set for it at Scheduled-Tasks->Task.Name->Properties->Settings. If you have this time set for a shorter duration than the task needs, it may appear that the task failed to finish because the computer went into standby while the task was still running, but the real reason is that a longer time has to be set. Or the box can be unchecked so there is no time constraint at all.
In task scheduler go to `properties - conditions tab - select 'Wake the computer to run this task'`. In W7 this also triggers the computer to **not** go to hibernate if the task is running
edit- as commenters have pointed out, this bug may not be fixed. I haven't experienced it which is why I figured it was fixed, but there are reports that it wasn't fixed between vista and 7, which is what the OP indicates. Three is [a thread](http://forum.acronis.com/forum/8985#comment-64200) over on Acronis with a script you can create and run with tasks that will stop the computer from hibernating. Additionally, there's a [post](http://iboyd.net/index.php/2010/10/15/scripting-a-scheduled-wakeup-in-windows-7-and-vista-too/) on this website about inserting `ping` into your tasks to stop the computer from hibernating.