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

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

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


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

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.