Abort/cancel system shutdown
By default when we issue shutdown command the computer will not shut down immediately. There are 60 seconds wait time before shutdown. We can cancel the shutdown operation with which/a means abort.
> shutdown /a
Force application to shut down )
I’m looking to force my application to shut down, and return an Exit code. Had a look on MSDN and I can see that in WPF the Application has a Shutdown method which takes an error code as a parameter, but there doesn’t appear to be one for System.Windows.Forms.Application.
I can see Application.Exit() but not a way to pass back an error code.
Does anyone know off-hand if this is possible?
Restart and record reason
shutdown /r /d p:0:0
In the above example, the shutdown command restarts the computer that’s currently being used and records a reason of Other (Planned). The restart is designated by /r, and the reason is specified with the /d option, with p representing that the restart is planned and the 0:0 indicating an “Other” reason.
Remember, major and minor reason codes on a computer can be displayed by executing shutdown without options and referencing the Reasons on this computer table that’s displayed.
Shutdown command & windows 8
Microsoft made it more difficult to shut down Windows 8 than they did with previous versions of Windows, prompting many to search out a way of shutting down through a command.
You can certainly do that by executing shutdown /p, but there are several other, albeit more accessible, ways of doing so.
With the return of the Start Menu in Windows 10, Microsoft again made shutting down your computer easy with the Power option.
Shutdown command availability
The shutdown command is available from the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP operating systems.
Shutdown command examples
Here are a few examples that show how to use the shutdown command:
Shutdown command syntax
The command follows the following syntax:
shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/f] [/m \computername] [/t xxx] [/d [p:|u:]xx:yy] [/c “comment”] [/?]
If you don’t know how to read command syntax, below is a breakdown of what all that means.
shutdown command syntax is like below.
shutdown OPTIONS COMPUTER COMMENT