The Computer Oracle

How can I put the computer to sleep from Command Prompt/Run menu?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Dream Voyager Looping

--

Chapters
00:00 Question
00:27 Accepted answer (Score 134)
01:43 Answer 2 (Score 102)
02:14 Answer 3 (Score 29)
02:53 Answer 4 (Score 13)
03:21 Thank you

--

Full question
https://superuser.com/questions/42124/ho...

Accepted answer links:
[this]: http://www.howtogeek.com/howto/windows-v.../
https://superuser.com/a/463652/249349
[Scott Chamberlain]: https://superuser.com/a/395497
[Eric L.]: https://superuser.com/a/578998
[PsShutdown]: http://technet.microsoft.com/en-us/sysin...

Answer 2 links:
[PsShutdown]: https://docs.microsoft.com/en-au/sysinte...

Answer 4 links:
http://www.nirsoft.net/utils/nircmd.html

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #commandline #sleep #shutdown #rundialog

#avk47



ACCEPTED ANSWER

Score 134


You will find shutdown.exe to be your friend.

Other handy commands see this post:

Sleep Computer (read more at https://superuser.com/a/463652/249349 )

Lock Workstation

Hibernate Computer - see answers by Scott Chamberlain and Eric L.

Restart Computer

Shutdown.exe -r -t 00

Shutdown Computer

Shutdown.exe -s -t 00

EDIT/UPDATE:

It seems that sleeping a computer is problematic if hibernate is turned on.

Copying from other answers:

You can either try PsShutdown or:

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



ANSWER 2

Score 107


The methods posted by other people do not work correctly if a computer has hibernation enabled, the computer will not wake on Keyboard or, more importantly, not wake on scheduled task.

One of Microsoft's Sysinternals tool is PsShutdown using the command psshutdown -d -t 0 it will correctly sleep, not hibernate, a computer




ANSWER 3

Score 31


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



ANSWER 4

Score 14


NirCmd workes on Windows 8 (I assume it also works with Windows 7) → http://www.nirsoft.net/utils/nircmd.html
The command is standby, but it puts the computer to sleep.

nircmd.exe standby

If you have hybrid sleep enabled, it will work; i.e., it puts the computer to sleep and copies the memory to disk in case of power loss.