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 :)

  • 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 Jul 7 '13 at 21:26
  • @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 Jul 8 '13 at 7:47
  • 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 Jul 8 '13 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.