What is the command to use to put your computer to sleep (not hibernate)?
Solution 1:
I found a solution. I installed a freeware program called AutoHotKey and recorded the steps to invoke Start Menu -> Sleep into a script file. Then I complied the script file into a stand-alone executable SleepWin7.exe.
Now I simply run SleepWin7.exe to put my computer into hybrid sleep.
You may uninstall AutoHotKey if this is all you need it for.
Update: The above solution doesn't work when the user isn't logged in, i.e. Windows 7 Login Screen. (My computer wakes up at 4am every Sunday to perform weekly backup, which is done without user login.) In such case, the Wizmo program still works:
wizmo.exe quiet standby!
Solution 2:
Hope you find these useful.
Shutdown %windir%\System32\shutdown.exe -s
Reboot %windir%\System32\shutdown.exe -r
Logoff %windir%\System32\shutdown.exe -l
Standby %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby
Hibernate %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate
Caution: rundll32.exe should not be used to launch powerprof.dll. Instead you should call SetSuspendState directly. This can be done using Powershell - create a file eg sleep.ps1, with the below contents.
Add-Type -Assembly System.Windows.Forms
[System.Windows.Forms.Application]::SetSuspendState("Suspend", $false, $true)
Then run it using powershell -File C:\your-path\sleep.ps1
. You may first need to run the command Set-ExecutionPolicy RemoteSigned
to enable powershell scripts to run.
The above script causes a system suspend, which will either sleep or hibernate depending on your current hibernate setting. To change that setting from the command line, run powercfg -h off
(or on
) from the command line as administrator.