Turning off the computer is one of the tasks that most users perform on a daily basis when they finish work. Something really routine and simple, since you just have to click on the Windows Start button and click on the shutdown option or use the keyboard shortcut Alt + F4, for example. However, things can get complicated when for some strange reason the Start button does not work or the graphical interface of the system has been blocked, for example. In this circumstance or whenever we want, it is important to know that we can turn off the computer from the command prompt or CMD.
What is the command prompt or CMD
The command prompt or also known as CMD for being the abbreviation of CoMmanD , is a command interpreter based on Windows and that is the equivalent of the famous command.com in MS-DOS.
In short, an application that allows us to perform or execute certain functions of the graphical interface but through commands that are sent to the cmd to execute them. In this way, we can execute certain functions that are also available from the graphical interface without using it and even others that are only available from the command line.
To use the command prompt, we must launch the application and once there, enter a valid command, along with any of its optionally accepted parameters. With the simple act of pressing Enter, the command will be sent and executed, as long as the syntax is correct.
Restart or shut down the computer from CMD
To restart or shut down the computer from the command line, we will have to use the shutdown.exe command. It is one of the CMD commands and the one that allows us to indicate if we want to restart or turn off the computer. To do this, the first thing we must do is know its syntax:
shutdown [/ i | / l | / s | / r | / a | / p | / h | / e] [/ f] [/ m <ComputerName>] [/ t <XXX>] [/ d [p | u:] <XX>: <YY> [/ c “comment”]]
/ i with this extension will display a graphical version of the system shutdown, restart and suspend functions.
/ l in this case will close the session immediately, regardless of the user who is using it.
/ s will be used to shut down a computer by typing its name.
/ r is the way to shut down and restart your computer remotely.
/ g same as / r, but reboot will be deeper.
/ a with this extension we will stop a scheduled shutdown.
/ p is used to shut down the computer permanently.
/ h thanks to this command the system will go into hibernation mode.
/ eWe enable documentation in the Shutdown Event Tracker, in case the system shuts down suddenly.
/ or we will log out and the Advanced Boot Options menu will open.
/ hybrid makes the computer do a quick reboot.
/ f if we use this extension all active programs will be closed automatically.
/ m is a command that used with ” \ name ” will shut down a specific computer remotely.
/ t just in the seconds that we put after the “t” the computer will be paid.
As we can see, it allows a lot of parameters to establish certain configurations or even to shut down the computer remotely, among many others. However, the most important parameters to order the computer to restart or shut down permanently are / s and / r.
Turn off the PC
Specifically, the / s parameter is the one that indicates that what we want to do is turn off the equipment. So, just type the command:
shutdown / s
and press Enter on the command line so that we can see how our computer shuts down automatically.
Now, within the syntax of the command itself, there are other parameters that can accompany the instruction to shut down the computer. For example, [/ t <XXX>], which allows us to configure the shutdown of the equipment after a certain time that we will establish in seconds. That is, if what we want is to shut down the system after two minutes since we launched the command, we must write the following at the command prompt:
shutdown / s / t 120
As soon as it is executed, a window will be shown in which the system itself will inform us that the computer is going to shut down within 2 minutes. If at any time the need arises to cancel this order and we do not want the computer to shut down, we can cancel the process by executing the shutdown / a command.
Restart your computer
On this occasion, the parameter that we must use to request a restart of the computer after shutting down is / r. Therefore, if what we want is to order a restart of the PC from the command line or CMD, this is the command we must execute:
shutdown / r
As we indicated when turning off the computer, it is also possible to indicate that the system waits a certain time before proceeding with the restart. To do this, we can use the same / t XXX parameter as follows:
shutdown / r / t 120
This will cause the computer to restart after shutting down after waiting two minutes from the moment we execute the command. We can also cancel this command by launching the shutdown / a command before the established time-out expires.
In addition to being able to restart our PC from the command prompt, something really useful is also being able to restart our computer remotely . From the previous link you can see different ways to restart or turn off our equipment from a distance.
From the command prompt we can execute another series of very useful commands. Here you can find some of the most basic network commands to use from the CMD.
Shut down or restart the PC quickly
These same commands that we have just mentioned to be able to shut down or restart the computer from the command line can be used to create a shortcut on the desktop and thus be able to execute them with a simple click without having to enter the CMD. To do this, the first thing we have to do is click with the right button of the mouse on a free space on our desktop and select the option New> Shortcut.
Next, a window will open in which we must indicate the location of the element. That is where we will have to write the command we want to execute, shutdown.exe -s, shutdown.exe -r or any of the variations or with the parameters mentioned above.
We click on Next, we give our shortcut a name and finally we click on Finish. Now we can see how a new shortcut appears on our desktop that we can click to restart or turn off the PC.