Shutdown A Windows System from Command Line

ShutDown.EXE [/shutdown][/restart][/poweroff][/logoff][/lockws][/hibernate][/standby][/fshutdown][/frestart][/fpoweroff][/flogoff][/flockws][/fhibernate][/fstandby][/hide][/show]

Switch      Description             Available for 

/shutdown   ShutDown Windows        Windows (all) 
/restart    Restart Windows         Windows (all) 
/poweroff   Power Off Windows       2000/XP/2003 
/logoff     Log Off curent user     Windows (all) 
/lockws     Lock WorkStation        Windows (all) 
/hibernate  Hibernate Mode          2000/XP/2003 
/standby    Standby Mode            Windows (all) 
/fshutdown  Force ShutDown Windows  Windows (all) 
/frestart   Force Restart Windows   Windows (all) 
/fpoweroff  Force Power Off Windows 2000/XP/2003 
/flogoff    Force Log Off curent user     Windows (all) 
/fhibernate Force Hibernate Mode    2000/XP/2003 
/fstandby   Force Standby Mode      Windows (all) 
/hide       Run ShutDown+ in Silent Mode     Windows (all) 
/show       Show the tray icon when running in Silent Mode     Windows (all) 
/? or /help Help screen  

OS (1) Command line Effect Remarks
DOS ECHO G=FFFF:0000 � DEBUG  Reboot Warm boot, sometimes cold boot.
May not work with “exotic” memory managers, like Quarterdeck’s QEMM or DesqView; in that case, use RESET.COM instead.
Win31* ECHO G=FFFF:0000 � DEBUG  Task Manager popup And sometimes reboot
Win9* RUNDLL USER.EXE,ExitWindows  Shutdown (2)   
Win9* RUNDLL USER.EXE,ExitWindowsExec  See Remarks Win95: various results, usualy fast shutdown (and lock PC), sometimes restart Windows, sometimes reboot.
Win98: Restart Windows, sometimes reboot.
Win9* RUNDLL SHELL.DLL,RestartDialog  Restart dialog “System Settings Changed, Do you want to restart your computer now?” dialog
Win98 RUNDLL32 KRNL386.EXE,exitkernel  Poweroff Poweroff for ATX boards only, otherwise normal shutdown (3)
Win98/ME RUNDLL32 SHELL32.DLL,SHExitWindowsEx n  See Remarks n can be any combination (sum) of the following numbers: (4)
0    Logoff
1    Shutdown
2    Reboot
4    Force
8    Poweroff (if supported by the hardware)
 
Win98/ME RUNONCE.EXE -q  Reboot (4)   
NT4 See Reboot NT on my Solutions found in alt.msdos.batch page Reboot Reboot immediately
NT4 RUNDLL32 USER32.DLL,ExitWindowsEx
RUNDLL32 USER32.DLL,ExitWindowsEx  Logoff Most systems require the command to be called twice before logging off
NT4+RK
W2K+RK SHUTDOWN /L /R /T:0 /Y  Reboot Immediate shutdown & reboot
NT4+RK
W2K+RK SHUTDOWN /L /T:10 /Y /C  Delayed shutdown Shutdown in 10 seconds, close without saving.
Can be stopped during those 10 seconds using SHUTDOWN /A
NT+ (1) PSSHUTDOWN \\mynt4srv -K -F -T 20  Delayed poweroff Poweroff \\mynt4srv after a 20 seconds delay
Can be aborted using PSSHUTDOWN \\mynt4srv -A
Uses PSSHUTDOWN.EXE from SysInternal.com’s PS Tools
NT+ (1) PSSHUTDOWN \\myw2ksrv -O -F -T 0  Logoff Immediately logoff console user on \\myw2ksrv
Uses PSSHUTDOWN.EXE from SysInternal.com’s PS Tools
W2K (5) DEVCON Reboot  Reboot Requires Microsoft’s DEVCON utility
W2K Click here and learn how to shutdown a remote Windows 2000 computer Shutdown GUI, no command line
XP SHUTDOWN -r -t 10  Delayed reboot Reboot after a 10 seconds delay.
Can be stopped during those 10 seconds using SHUTDOWN -a
XP SHUTDOWN -s -t 01  Delayed shutdown Shutdown after a 1 second delay, NO poweroff.
TS LOGOFF 16 /SERVER:termserv1  Logoff Logoff session 16 on Terminal Server TERMSERV1.
Use the QUERY USER command to find out which session ID belongs to whom.
More Terminal Server commands here.
TS TSSHUTDN 45 /SERVER:termserv1 /POWERDOWN /DELAY:20 /V  Delayed poweroff Notify all users on Terminal Server TERMSERV1, logoff all Terminal Server sessions after 45 seconds, wait another 20 seconds, and then shut down Terminal Server TERMSERV1 and power off.
See my Terminal Server Commands page for the exact syntax.
Kix RC = SHUTDOWN( “\\server”, “Shutting down…”, 10, 1, 0 )  Delayed shutdown Shutdown \\server in 10 seconds, with message, close without saving, no reboot
Kix
RC = SHUTDOWN( “\\server”, “”, 0, 1, 1 )  Reboot Immediate shutdown & reboot \\server, without a message
Kix RC = LOGOFF( 1 )  Logoff Forcing applications to close.
Use 0 instead of 1 if you don’t want to force applications to close
Perl InitiateSystemShutdown(
sComputer, sMessage,uTimeoutSecs, bForce,bReboot )    General syntax (ActivePerl for Windows only)
Perl InitiateSystemShutdown( “”, “”, 0, 1, 1 )  Reboot Immediate reboot without message, force applications to close without saving data
Perl InitiateSystemShutdown( “”, “Going down…”, 10, 0, 1 )  Delayed reboot Reboot after 10 seconds, with message and without forcing applications to close
Perl InitiateSystemShutdown( “10.0.1.16”, “Sorry”, 5, 1, 0 )  Delayed shutdown Shutdown of remote computer after 5 seconds, with message and forced closing of applications
Regina Rexx RC = W32SysShutdown( how [,force] )    General syntax (Regina Rexx for Windows with W32Funcs only).
how can be either Reboot, Logoff, Poweroff or Shutdown.
force can be either Force or Noforce.
Regina Rexx RC = W32SysShutdown( “P”, “F” )  Poweroff Immediate shutdown and poweroff, forced closing of application
Regina Rexx RC = W32SysShutdown( “L”, “N” )  Logoff Logoff, prompt for saving unsaved data
WSH [1] Set OpSysSet = GetObject(“winmgmts:{(Shutdown)}//./root/cimv2”).ExecQuery(“select * from Win32_OperatingSystem where Primary=true”)
[2]
[3] for each OpSys in OpSysSet
[4]     OpSys.Reboot()
[5] next  Reboot Requires WMI.
Remove [line numbers].
(Found in a forum posting by Alex K. Angelopoulos on www.developersdex.com)
WSH Replace line 4 in the script above with this one:
[4]     OpSys.Shutdown()
to shut down the PC instead of rebooting it. Shutdown But no poweroff.
 
See my WSH page for examples on how to reboot or shut down remote computers too.
WSH [1] Const EWX_LOGOFF = 0
[2]
[3] Set wmi = GetObject(“winmgmts:{(Shutdown)}”)
[4] Set objSet = wmi.InstancesOf(“Win32_OperatingSystem”)
[5]
[9] For Each obj in objSet
[6]     Set os = obj
[7]     Exit For
[8] Next
[9]
[10] os.Win32Shutdown EWX_LOGOFF  Logoff Requires WMI.
Remove [line numbers].
(Posted by Michael Harris on microsoft.public.scripting.vbscript)
 
My Logoff.vbs combines this code with that of the reboot and shutdown commands, and allows logoff of remote computers as well.
OS/2 START /PM SHUTDOWN && EXIT  Shutdown Will still stop and ask for confirmation if a non-PM application is active
OS/2 SETBOOT /B  Reboot Unconditional shutdown & reboot from default Boot Manager entry.
(Mailed by Rick Curry)
OS/2 SETBOOT /IBD:C:  Reboot Unconditional shutdown & reboot from C: drive
OS/2 SETBOOT /IBA:nonsense  Shutdown Unconditional shutdown & failing reboot.
Needs Boot Manager installed.
Will reboot, no questions asked, and then stop if nonsense is an invalid Boot Manager menu entry (which, in this case, is exactly what we want).
OS/2 LOGOFF  

#include <sys/socket.h>
int shutdown(int s, int how);

[tags]command,windows,shutdown,halt,code,xp,2000,98[/tags]

Author: Binny V A
A philosopher programmer who specializes in backend development and stoicism.

7 thoughts on “Shutdown A Windows System from Command Line

  1. Hi Doufer,
    The shutdown.exe is a file that is included with Windows. It can be found at the location ‘C:\windows\system32\shutdown.exe'(in XP)

  2. ou have to copy shutdown.exe from a Windows XP machine. Copy it from c:\windows\system32 from the XP machine to c:\windows\system32 on the Windows 2000 PC.

Leave a Reply

Your email address will not be published. Required fields are marked *