How to Shut Down, Restart, or Put Your Computer to Sleep via Command Line in Windows
Managing your computer's state through the command line in Windows can be a convenient alternative to using the graphical interface. In this guide, we'll show you how to shut down, restart, or put your computer to sleep using simple commands.
1. How to Shut Down Your Computer
To shut down your computer via the command line, use the following command:
shutdown /s /f /t 0
Here's what each part of the command means:
- /s — tells the system to shut down.
- /f — forces all running applications to close (warning: unsaved data may be lost).
- /t 0 — sets the delay to 0 seconds (the shutdown happens immediately).
2. How to Restart Your Computer
To restart your computer, use this command:
shutdown /r /f /t 0
Explanation of the parameters:
- /r — tells the system to restart.
- /f — forces all running applications to close.
- /t 0 — sets the delay to 0 seconds, so the restart happens immediately.
3. How to Put Your Computer to Sleep
To put your computer into sleep mode from the command line, use the following command:
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
This command triggers sleep mode without turning off the display. If you prefer the computer to turn off the display first, use this command:
rundll32.exe powrprof.dll,SetSuspendState Sleep