Yes, that is exactly as expected. Sadly, all the suggestions utilizing the "rundll32.exe powrprof.dll,SetSuspendState 0,0,0" or "rundll32.exe powrprof.dll,SetSuspendState Sleep" command are mislead. It is not supposed to work, and does so in certain
circumstances inadvertently. The SetSuspendState function expects three parameters:
- Hibernate (Boolean; Standby if false)
- Force (Boolean)
- NoWakeTimers (Boolean)
All would be fine and dandy if Rundll32 passed the parameters on as specified.
However, it does not. Rundll32 uses the
following preset parameters, regardless of the arguments passed to it:
- hWnd (dWord preset to the parent window specified in the start command for Rundll32)
- hInst (dWord preset to the loaded instance of the specified DLL)
- sCmdLine (address to string containing all the arguments you passed to Rundll32)
- nCmdShow (dWord preset to the start mode you ran Rundll32 with, e.g. minimized, maximized, normal, normal no focus).
All those parameters will be non-zero numbers regardless of what you specify in the command line. Therefore, any call to
SetSuspendState from Rundll32 will equal calling
SetSuspendState (True, True, True), which asks the system to force hibernate and disable all scheduled tasks that are scheduled to wake the computer up. Disabling hibernation and then asking Windows to enter hibernation is not a very good
workaround to accomplish standby.
So, here are some valid commands:
| Lock |
rundll32 user32,LockWorkStation |
| Log off |
shutdown -l |
| Restart (requires admin) |
shutdown -r -t 0 |
| Full Shutdown (requires admin) |
shutdown -s -t 0 |
| Fast Shutdown (requires admin) |
shutdown -s -t 0 -hybrid |
| Hibernate |
shutdown -h |
| Standby (requires PsShutdown tool) |
psshutdown -d -t 0 |
Unfortunately, after all the features it has, the Microsoft shutdown command is missing the standby feature! So, it you want to put your computer to sleep via command line, you'll need to install a more capable tool before you can use
the last command above:
- Download Sysinternals PsTools.
- The download should be a ZIP file. Open it and copy PsShutdown.exe to your desktop.
- On your desktop, right-click PsShutdown.exe and click Copy. Right-click it again and click Properties.
- Tick Unblock and click [OK].
- Open File Explorer, navigate to "C:\Windows", scroll down, right-click the system32 folder and click Paste.
- To enter standby, you can now use this command: psshutdown -d -t 0