I know that almost everything on windows [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?

link|improve this question

feedback

7 Answers

up vote 14 down vote accepted

You will find shutdown.exe to be your friend.

Other handy commands see this post:

Shutdown Computer

Shutdown.exe -s -t 00

Restart Computer

Shutdown.exe -r -t 00

Lock Workstation

Rundll32.exe User32.dll,LockWorkStation

Hibernate Computer

rundll32.exe PowrProf.dll,SetSuspendState

Sleep Computer

rundll32.exe powrprof.dll,SetSuspendState 0,1,0
link|improve this answer
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
1  
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
If you read the linked page, you will find the necessary commands all listed nicely with explanations. Unwarranted downvotes FTW! :P – brandstaetter Dec 21 '10 at 12:42
2  
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 Rory or Isznti May 19 '11 at 4:36
show 4 more comments
feedback

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
link|improve this answer
1  
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
feedback

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

wizmo standby

link|improve this answer
feedback

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.

link|improve this answer
feedback

Type shutdown on the command prompt and take a look at the output works on XP and above from what I can tell.

link|improve this answer
feedback

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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