How to shut down or restart the computer with a batch file

Below are steps on how to restart, shutdown, and hibernate a Windows computer from a batch file or the command line.

Windows Vista, 7, 8, and 10

Microsoft Windows Vista, 7, 8, and 10 includes a command to shutdown the computer through the command line, shortcut, or batch files. Below are the steps required for creating a shutdown, restart, and hibernate shortcut.
  1. Create a new shortcut.
  2. For the location of the shortcut type one of the below commands depending on what you want to do.

To shutdown the computer type the below line in the location text field.

shutdown.exe /s /t 00

To restart the computer type the below line in the location text field.

shutdown.exe /r /t 00

To hibernate the computer type the below line in the location text field.

shutdown.exe /h
  1. Click Next, and then for the name of the shortcut type either Shut down, Restart, or Hibernate and then click Finish.
After completing the above steps, double-click the shortcut icon to shut down, restart, or put the computer into hibernation.
Tip: After the shortcut has been created you can assign the shortcut a keyboard shortcut to shutdown the computer using the keyboard.
Tip: If you want to create a batch file you can add any of the above shutdown commands into the batch file with any other commands.