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 :)
powercfg -lastwake
.