Why shutdown command does not work in Task Scheduler in Windows 7?

I've added a shutdown /h /t 120 to the Task Scheduler in Windows 7. I've set it to be run only if my administrator user is logged in and with highest privileges. But it does not work.

When I fire the command from cmd it does not work. I am able to hibernate from Start menu.

Shutdown /s on the other hand works from cmd and from Task Scheduler.

How to hibernate windows 7 properly from Task Scheduler?


shutdown.exe does not allow the /t parameter to be used along with either /l (log off) or /h (hibernate) for some reason.

You can make the task execute shutdown /h (i.e. without /t) to hibernate. If you want a window wherein you can cancel the scheduled hibernation (using Ctrl+C), make the task execute cmd.exe instead with the following arguments:

/c "timeout /t 120 /nobreak && shutdown /h"

1

Remember to use && and not &, or else the second command (shutdown /h in this case) will run irrespective of whether the first one (timeout /t 120 /nobreak) was cancelled or not.