Sleeping a computer via batch file in Windows 7
Solution 1:
Simply command
rundll32.exe powrprof.dll,SetSuspendState
Does system hibernate, but if you write this:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
And turn off hibernation with command:
powercfg -hibernate off
Now your system will go asleep, and will wake up on mouse move if selected a device for it (scroll down to learn how).
Batch a timer:
timeout /t 1200
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Where 1200 is seconds, which mean after 20 minutes batch will run sleep command.
Optionally you can prevent canceling countdown (if you press any key in batch window):
timeout /t 1200 /nobreak
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Little HOWTO about waking up with mouse:
Go to: Start -> Control Panel -> Mouse.
In the Mouse Properties window, click on the Hardware tab and select your mouse from the list of devices. Normally, there will only be one mouse listed here but that will depend on the hardware you have connected to your computer. When you have selected your mouse from the list, click the Properties button.
Now in the Properties window for your mouse, click on the Change Settings button on the General tab.
In the window that opens, click the Power Management tab and check the option titled Allow This Device to Wake The Computer. Click the OK button on this window and click the OK button on the Mouse Properties windows that is still open. From now on, you can wake up Windows 7 from sleep mode by clicking a mouse button or moving the mouse around.
Solution 2:
shutdown /h
will hibernate the computer (not sure about suspend though).
Solution 3:
Working Solution!
I had to use the PsShutdown
utility to allow proper sleeping (primary issue is SetSuspendState
does not allow wake timers to wake up the machine). My batch file to sleep is 1 simple line:
PsShutdown -d -t 2