Windows Command-Line – How to Put Computer to Sleep from Command Prompt or Run Menu

command linerun-dialogshutdownsleepwindows

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?

Best Answer

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
Related Question