Windows XP can be shut down from the (eventually DOS prompt) command line box.
This is the Shutdown.exe (located in %systemroot%\System32, usually C:\Windows\System32) syntax:
- shutdown [-i|-l|-s|-r|-a] [-f] [-m \\computername] [-t xx] [-c "Text"] [-d[u][p]:xx:yy]
Valid Command line switches:
- -a = Abort system shutdown in progress ONLY IF the -t xx timeout option was already set to ANY value other than 0. ALL switches except -l and -m are ignored during abort.
- -c "Text" = Text comment (case insensitive) to be displayed in the Message area of the System Shutdown window. MUST be enclosed between quotes. Maximum allowed 127 ASCII characters.
- -d [u][p]:xx:yy = Reason code for shutdown:
- u = User code.
- p = Planned shutdown code.
- xx = Major reason code. Positive integer number less than 256.
- yy = Minor reason code. Positive integer number less than 65536.
- -s = Shut down the local computer.
- -r = Shut down and restart (reboot) the local computer.
- -f = Force running applications to close without warning.
- -l = Log off the current user of the local computer (default action). Can NOT be used with the -m option unless the current user has Sysadmin rights, in which case the -m switch takes precedence.
- -m \\computername = Remote/network computer name (most always case sensitive) to log off/restart/shut down. Current user MUST have Sysadmin rights to be allowed to use this switch!
- -t xx = Set shutdown timer to timeout for xx seconds. IF NOT specified defaults to 20 seconds. Allowed values between 0 and 99 seconds. The -a switch is the ONLY one that CAN be used during the timeout period.
The dash (-) in front of these switches can be replaced by a forward slash (/).
Ok let's start creating a sample .bat file that shuts down your local computer in 3 seconds and displays a message "Shut down" ...
- Open notepad
- Copy and paste the code below
- shutdown -s -c "Shutting down!" -t 3
- Save as "shutdown.bat"
- Double click the .bat file created.
And it's done, amazingly you've created a .bat file to shut down your PC...
How would you like putting this file at the statup of someones computer? :)