Breaking News

Reference number: CH000321 How to shut down / restart the computer with a batch file.

Issue:

How to shut down / restart the computer with a batch file.

Reasoning:

It 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.

Solution:

MS-DOS Users

Windows 95, Windows 98 and Windows 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 may also perform the below command to perform different types 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

Windows XP users

Microsoft Windows XP includes a new shutdown command that will enable a user to shutdown the computer through the command line and/or batch files.

Syntax

Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u] [p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

Examples

shutdown -r -c "Rebooting for latest updates."

This would display a Windows System Shutdown window for 30 seconds, warning the user that the computer is going to shutdown and then restart the computer.

shutdown -i

Ran from either the command line or from the Windows run line this option would open the remote shutdown dialog Window.

No comments

please write your mail id for contact: