Shuts down, restarts, or logs off the system.
|Code||A combination of shutdown codes listed below.|
The shutdown code is a combination of the following values:
|Suspend/Hibernate||See DllCall example at the bottom of this page.|
Add the required values together. For example, to shutdown and power down the code would be 9 (shutdown + power down = 1 + 8 = 9). Alternatively, an expression such as 1+8 can be specified.
The "Force" value (4) forces all open applications to close. It should only be used in an emergency because it may cause any open applications to lose data.
The "Power down" value shuts down the system and turns off the power.
On a related note, a script can detect when the system is shutting down or the user is logging off via OnExit.
Run, ExitApp, OnExit
; Force a reboot (reboot + force = 2 + 4 = 6): Shutdown, 6 ; Call the Windows API function "SetSuspendState" to have the system suspend or hibernate. ; Windows 95/NT4: Since this function does not exist, the following call would have no effect. ; Parameter #1: Pass 1 instead of 0 to hibernate rather than suspend. ; Parameter #2: Pass 1 instead of 0 to suspend immediately rather than asking each application for permission. ; Parameter #3: Pass 1 instead of 0 to disable all wake events. DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)