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?
Solution:
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 PsShutdownor:
The command rundll32.exe powrprof.dll,SetSuspendState 0,1,0 for sleepis correct – however, it will hibernate instead of sleep if you don’tturn the hibernation off.
Here’s how to do that:
Go to the Start Menu and open an elevated Command Prompt by typingcmd.exe, right clicking and choosing Run as administrator. Type thefollowing command:
powercfg -hibernate off