Looking for a Shell command (or API call) to emulate Sleep

Gulliveig

New Member
Messages
1
Good day,

In Win 8.1, I have set the following power button options:

Control Panel > Power Options > Choose what the power buttons do:
When I press the power button = Sleep.
Password protection on wakeup = Don't require a password.
"Turn on fast startup" is checked.

This does the following:

(1) When I press the power button, my system shuts down perfectly well, within a few seconds my harddisk blinkenlight goes from flashing blue to a sleepy orange.
(2) After that, I do physically disconnect the power supply (power cable).
(3) After several hours, I re-attach the power cable, and without further a-do (not even switching on the power button), the system is there where it was before doing (1).

Is there a shell command, which simulates exactly this shutdown behavior?

Shutdown.exe does not seem to have an appropriate argument, all tested options fail on (3): in most cases I have to manually switch on the power button and then go through the login procedure, i.e. swipe the intro screen away etc.

Alternately, is there an API function I can use? (Neither InitiateSystemShutdown nor SetSystemPowerState seem to work here, the former requires formal log-in, the latter shows no reaction on my notebook, whether fSuspend is True or False).

Thanks in advance!
 

My Computer

System One

  • OS
    Win 8.1
    Computer type
    PC/Desktop
Windows only allows the hardware Power button or the Start Menu/Start screen power button to enter Sleep (standby) mode. It does not provide a command line tool to directly enter sleep.

If hibernation is disabled on your PC, you can enter Sleep mode using the following command:

rundll32.exe powrprof.dll,SetSuspendState 0,1,0

But if you have enabled hibernation, then the above command hibernates the PC instead of entering sleep mode. So you need to apply a workaround which isn't exactly ideal, something like this.

powercfg -h off
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
powercfg -h on


In the example above, I've used the powercfg command to disable hibernation, just before using the Rundll32 command. Then the rundll32 command will work correctly and put the PC into sleep. When it wakes up, the last line will turn on hibernation. Another issue with this workaround is that it must be executed from an elevated command prompt.


OR

You can enter sleep without disabling hibernation and without requiring elevated (administrator) privileges.

Download the PsShutdown tool by SysInternals. Using this tool, you will be able to make the PC enter sleep mode directly by giving a single command:

psshutdown.exe -d -t 0 -accepteula
 

My Computer

System One

  • OS
    Win 8 and Linux (MINT)
    Computer type
    Laptop
    System Manufacturer/Model
    Lenovo Win 8 & Toshiba Linux
    Monitor(s) Displays
    Samsung SyncMaster
Back
Top