Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I know that almost everything on Windows, like opening any sort of application, can be done from the command prompt or from the Run menu.

How can I put my computer to sleep or shut it down? What is the command for that?

share|improve this question
    
Type shutdown on the command prompt and take a look at the output works on XP and above from what I can tell. –  user10547 Sep 16 '09 at 14:20

9 Answers 9

up vote 63 down vote accepted

You will find shutdown.exe to be your friend.

Other handy commands see this post:

Sleep Computer

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

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
share|improve this answer
9  
Problem with rundll32.exe powrprof.dll,SetSuspendState 0,1,0 is that IT DOES NOT WORK as it should. SetSuspendState will put the computer into a sort of Hybrid Sleep/Hibernation mode. When you use the Sleep button from the start menu, you can resume your computer from sleep by pressing a any key on your keyboard. Using this command line, makes is resume much slower due to the deeper sleep state and it can resume only if you press the power button on your computer. It cannot resume for a key press. So... how do you make it sleep as in normal standby - resumable with the press of a key? –  Corporate Geek Feb 14 '10 at 12:29
2  
If you have permissions you can use shutdown.exe to initiate a remote shutdown of another computer on your network. Can be good for pranks. (No responsibility taken) –  Matthew Lock Apr 28 '10 at 5:33
2  
Downvoted because this doesn't actually answer the question (how to trigger a sleep). Shutdown.exe does NOT trigger a sleep, only shutdown, restart or hibernate. To sleep, you need to run: rundll32.exe powrprof.dll,SetSuspendState 0,1,0 –  Nicholas Oct 31 '10 at 18:20
4  
The downvotes are not in the least unwarranted. Your answer does not address the question on its own. Readers should be able to gather enough useful information from an answer to solve the problem without having to follow any links to other sites which may become broken or dead. –  Iszi May 19 '11 at 4:36
4  
I have tested the Sleep command as well, and can also confirm that it does not work as intended. It has nothing to do with hating/trolling, but if that command does not work, then the question is unanswered, since that was the main part of the question. –  reSPAWNed Feb 3 '12 at 11:28

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

share|improve this answer

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
share|improve this answer
4  
I think it's the first answer that actually solves it. I put these two lines (-hibernate off first) and made a batch file that puts the pc to sleep. One problem with that is that it essentially turns off hibernation, which is not what I wanted, so to fix it, I added a scheduled task triggered on "on workstation unlock" to turn the hibernation back on with a batch whose only line is "powercfg -hibernate off". Then I configured a short key for the first batch file. Done. Works like a charm, thank you! –  akurtser Aug 24 '11 at 11:44
    
That is so weird. Hibernation needs to be turned off before you can sleep properly? Is there a name for the hybrid sleep/suspend state powrprof.dll is when hibernate is on? Just want to know. Does it relate to any of the ACPI states? –  Ehtesh Choudhury Sep 12 '12 at 16:19

See the free utility of Wizmo, which can do very many things.
The command you're looking for is probably:

wizmo standby

share|improve this answer
1  
Wizmo has the same problem as rundll32.exe powrprof.dll,SetSuspendState 0,1,0 -- it puts the computer in hibernation, not in sleep –  Andomar Aug 19 '12 at 18:53
    
No, since Vista it actually puts the computer in Hybrid Sleep. If you don't want this, then Turn Off Hybrid Sleep‌​. –  harrymc Aug 19 '12 at 20:26

You can initiate the suspend or hibernate options from the command line as specified below and referenced in this article.

%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState

If your computer is set to allow hibernation then the above command will initiate hibernation. If the hibernation feature is disabled, then it will enter the standby state. As other users have answered previously, shutdown.exe /? will provide many shutdown options.

share|improve this answer

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; ie puts computer to sleep and copies the memory to disk in case of power lost.

share|improve this answer

Here's an article on using CLI to shutdown.

Microsoft provides PsTools which gives you CLI shutdown along with other useful tools. You can get that here.

share|improve this answer

You must first disable Hibernate in windows and then put the computer in Sleep state. Use following two commands:

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

and for doing reverse action, Hibernating the computer, use commands below:

powercfg -hibernate on
rundll32.exe powrprof.dll,SetSuspendState Hibernate
share|improve this answer

For shutdown, type

shutdown -i

at the command prompt for a gui, or /? for all the valid switches.

I am not sure of a quick command for standby.

share|improve this answer
    
That command allows you to shutdown a remote machine. Also, it doesn't include a sleep option. –  Jeremy Stein Dec 10 at 20:14

protected by Nifle Aug 20 '12 at 16:52

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.