How to shutdown windows computer from the DOS Prompt – what command to use

This off-topic from Java but might sometimes be needed for a java developer so thought of posting it. It’s a kind of windows tips.

Sometimes, you might not be able to shutdown the computer from the windows due to some policies setup for that machine. For example I am not allowed shut down a shared machine or a server that is running application server. There is a hack. An alternate way to shutdown and restart the computer is to pass the shutdown command from the dos prompt. I have always been successful.

  • Shutdown –s [shutdowns the computers]
  • Shutdown –r [restarts the computer]
  • Shutdown –l [logs off the computer]
  • There are several other parameters that you can pass to shutdown command. Simply runt he command shudown/? to see other flags that you can pass to this dos command.
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)