Saturday, June 12, 2010

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

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

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

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. Additional information about this command can be found on our shutdown command page.

Additional information:

· Additional information about the rundll and rundll32 files can be found on document CH000570.

No comments:

Post a Comment