Automatically Shutdown Or Restart Windows Using The Command Line (CMD)

What is the command line?

The command line, also called the command prompt or cmd, is a text based user interface, that means that the only way to interact with it to type commands, a command is a word that tells the command prompt to act in a specific way or complete a specific task.

Some tools and commands within the command line are extremely useful and cannot be accessed otherwise, making the command line particularly necessary for high level codding and system administration. For now however we are just going to use it to shutdown or reboot our system automatically.

There is a myriad of tools and commands you can use to complete any task with the command line. Among those we can use the shutdown command to create shutdown timers, restarting your system, logging out or opening the advanced start options.

Opening the command line:

To use the shutdown command to automatically shutdown or restart our system we must first open the command line.

There are lots of ways you can open the command line, the simplest however is to search for “
Cmd” in your search bar and select the first result.

Automatically Shutdown Or Restart Windows Using The Command Line (CMD)

The command line should appear at once.

With the command line open we can now create our shutdown timer.

Automatic Shutdown Timer:

To automatically shutdown your PC type the following into your command line:

shutdown /s /t 7200

Lets break it down:

/s parameter tells the shutdown command to shutdown your system.

/t specifies the time in seconds. You can remove this parameter completely to shutdown your system in one minute.
Otherwise, adjust the value of this parameter to suit your needs. If you are unsure use the following cheat-sheet:

1 Hour = 3600.
2 Hours = 7200.
3 Hours = 10800.

X Hours = X * 3600.

Restarting Your System:

To automatically restart our system we are going to use the shutdown command once again, this time however instead of the
/s parameter we are going to use /r parameter which stands for restart or reboot, along with the /t parameter which specifies the time in seconds like i said before. This is what the complete command  should look like:

shutdown /r /t 7200

To change the amount of time change the value of the
/t parameter.

Cancel a shutdown or a restart:

Change your mind? No problem.
To cancel a scheduled shutdown ore restart simply type the following into your command prompt:

shutdown /a

The /a parameter stands for abort, and it will cancel any scheduled timer at once.

Useful Parameters:

You can use the shutdown command to complete a variety of operations, here is a list of useful parameters.

  • /l Stands for logout and it can be used to logout the current user.
  • /h Will hibernate your computer.
  • /f Will forcefully close any running applications before shutting down or rebooting.
  • And finally you can use /r followed by /o to restart your computer and launch the Advanced Start Options menu which is very useful for troubleshooting windows problems.

If you want the full list of parameters along with a brief description simply type:

help shutdown

A list with every available parameter for the shutdown command should immediately appear.

Automatically Shutdown Or Restart Windows Using The Command Line (CMD)

That's it:

You now have the knowledge and the ability to create automatic shutdown timers, reboot, logout or hibernate your system from the command line as well as opening the advanced start options menu with just a simple command.

Want to learn more about the Command Line?

Available on Udemy with a 70% discount.
Only for readers like you!

Follow by Email
Scroll to top