I have found a lot of info about how to shut down computer, put it in hibernation etc via the command line, however, any tips i have read about getting it to sleep as it does from the start-menu has so far not worked properly.
I would like a command that puts the computer in a light standby mode where a keypress would make the computer wake again, and not in hibernation. Does anyone know of this?
AFAIK, rundll32.exe powrprof.dll,SetSuspendState 0,1,0 does NOT put the computer to sleep / standby in all cases, and is as such not appropriate for my use...
Thanks, Araho
At the command prompt, type powercfg.exe /hibernate on , and then press Enter. Type exit, and then press Enter to close the Command Prompt window.
To set your PC so it goes to sleep when you close the lid or press the power button: Open power options—select Start , then select Settings > System > Power & sleep > Additional power settings.
/bin/sleep is Linux or Unix command to delay for a specified amount of time. You can suspend the calling shell script for a specified time. For example, pause for 10 seconds or stop execution for 2 mintues. In other words, the sleep command pauses the execution on the next shell command for a given time.
Thanks to @minitech, I finally got it working. Leaving this here for all who want to know the answer, and giving two examples, one in direct command-line and one in Visual C#:
Add elevated priveleges to your app:
Then run the following commands:
In commandline:
"powercfg -hibernate off" - This shuts off the hibernation mode possibility.
rundll32.exe powrprof.dll,SetSuspendState 0,1,0 - This makes the computer sleep.
powercfg -hibernate on - This allows the hibernation mode to again be activated.
In Visual C#, use the following code:
System.Diagnostics.Process.Start("powercfg", "-hibernate off"); // Turn off hibernation mode setting.
System.Diagnostics.Process.Start("rundll32.exe", "powrprof.dll,SetSuspendState 0,1,0"); // Send the computer to sleep
System.Diagnostics.Process.Start("powercfg", "-hibernate on"); // Turn on hibernation mode setting after waking computer.
It is very important to remember to add Administrator priveleges, or it will make the computer hibernate, which takes forever.
Araho
STANDBY (SLEEP) with CMD (command prompt or .bat), doesnt work in Windows 10.
Use QUICK SLEEPER.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With