Conditionally put back computer to sleep after task finished

0

I have a task scheduled that runs periodically every few hours. I'd like to allow it to wake computer from sleep state and based on how that task finished (perhaps based on exit code, or some other way) put computer back to sleep. Is that possible natively in Windows, or with some advanced task scheduler extension to windows? I put my computer to sleep on-demand only, so leaving it running after task finished isn't an option, as it won't put it back to sleep by itself.

I'd be willing to write some program myself that would run after task finished, but I have no idea if Windows even report if the task woke up computer, and if you can access it programmatically somehow.

Any advice is appreciated :)

Andrew

Posted 2013-07-07T18:09:46.883

Reputation: 261

What is the task? If it's an EXE, can you detect its exit status somehow? If so, why not schedule a batch file or VB/PowerShell script that runs the program, confirms its exit status and sends the PC to sleep if required? – Karan – 2013-07-07T21:26:43.963

@Karan It's python script, so yes, could be considered an executable :) Problem with your suggestion is it would put my computer to sleep even during the day when I use my computer. That's why I need to figure out how to detect if it was woken up to perform the task. – Andrew – 2013-07-08T07:47:31.507

One possible solution to that would be to make the sleep portion contingent on the time of the day. You can also take a look at the output of powercfg -lastwake. – Karan – 2013-07-08T16:31:14.820

No answers