Tuesday, November 29, 2016

How to control Windows Shutdown, Sleep, Hibernate ect by Command Line

There are 3 utilities we can use:shutdown.exe , powercfg and PowerProf.dll


Sleep Computer (read more at http://superuser.com/a/463652/249349 )
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
Lock Workstation
Rundll32.exe User32.dll,LockWorkStation
Hibernate Computer
rundll32.exe PowrProf.dll,SetSuspendState
Restart Computer
Shutdown.exe -r -t 00
Shutdown Computer
Shutdown.exe -s -t 00
Sleep from windows task command :
exec show "C:\Windows\System32\rundll32.exe" Powrprof.dll,SetSuspendState Sleep
There are issues with sleep when hibernate is enabled & many confuse the 2 commands:
Another Utility from SysInternals PsShutdown and NirCmd has some very handy utils.
 
The command rundll32.exe powrprof.dll,SetSuspendState 0,1,0 for sleep is correct - however, it will hibernate instead of sleep if you don't turn the hibernation off.
Here's how to do that:
Go to the Start Menu and open an elevated Command Prompt by typing cmd.exe, right clicking and choosing Run as administrator. Type the following command:
powercfg -hibernate off



Additional commands see this post:

No comments:

Post a Comment