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

Batch fileIt may be necessary after a batch file is completed its copying or installing process to restart the computer to complete that installation. Below are steps that can be used to restart a computer through a batch file.

Windows Vista, 7, and 8 users
Windows XP users
Windows 95, 98, and ME users
MS-DOS users

Windows Vista, 7, and 8 users

Microsoft Windows Vista, 7, and 8 includes a similar shutdown command feature that XP did 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 shut down your computer type the below line in the location.

shutdown.exe /s /t 00

To restart the computer type the below command in the location.

shutdown.exe /r /t 00

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

shutdown.exe /h

3. Click Next, and then for the name of the shortcut type either Shut down or Hibernate and then click Finish.

Once the above steps have been completed double-clicking on the new shortcut will shut down the computer or put it into hibernation.

Additional information and options about the shutdown command can be found on the shutdown command page.

Windows XP users

Microsoft Windows XP includes a new shutdown command that will enable a user to shutdown the computer through the command line, shortcut, or batch files. Below are the steps required for creating a shutdown and restart 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 shut down your computer type the below line in the location.

shutdown.exe -s -t 00

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

shutdown.exe -r -t 00

3. Click Next, and then for the name of the shortcut type either Shut down or Hibernate and then click Finish.

Once the above steps have been completed double-clicking on the new shortcut will shut down the computer or put it into hibernation.

Additional information and options about the shutdown command can be found on the shutdown command page.

Windows 95, 98, and ME users

Restarting the computer

START C:\Windows\RUNDLL.EXE user.exe,exitwindowsexec
exit

Shut down the computer

C:\Windows\RUNDLL32.EXE user,exitwindows
exit

Note: When typing the above two lines, spacing is important. It is also very important that the exit line be placed into the batch file as many times Windows may be unable to restart the computer because of the open MS-DOS window.

Microsoft Windows 98, and Windows ME users can also run the below command to perform different forms of rebooting or shutting down.

rundll32.exe shell32.dll,SHExitWindowsEx n

Where n is equal to one of the below numbers for the proper action.

  • 0 - LOGOFF
  • 1 - SHUTDOWN
  • 2 - REBOOT
  • 4 - FORCE
  • 8 - POWEROFF

MS-DOS users

If the computer needs to be restarted from MS-DOS, see the debug page for additional information on how to do this.

Additional information