By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

AutoIt Shutdown Function

Reference on the Shutdown function of AutoIt, includes a list of codes to be used with shutdown.

Edited: 2014-01-04 18:27

The AutoIt Shutdown function can be used to control the state of the computer, for example to put the computer into sleep or hibernation. But it also allows to logoff, to restart the computer, and to shutdown Windows.

The Power Down option is used to physically turn off the computer, after shutting down, (given that the hardware supports it). It however seems that Power Down does the same as shutdown, at least on Windows XP and up. That is, it attempts to close open programs, then shutdown Windows, and then turn off the power, regardless of which of the codes you use.


code The code can either be one, or a combination of codes.


The possible values for the code parameter is listed below:

$SD_LOGOFF (0)Logs the user off.
$SD_SHUTDOWN (1)Shuts down Windows.
$SD_REBOOT (2)Reboots the system.
$SD_FORCE (4)Used in combination with other codes, to "force" an action.
$SD_POWERDOWN (8)Used to turn off the power to the computer.
$SD_FORCEHUNG (16)Attempts to force the system to react if hung.
$SD_STANDBY (32)Saves the work in memory, and goes into sleep.
$SD_HIBERNATE (64)Saves the work on disk, and goes into hibernation.

Return Value

  1. 1 on Success
  2. 0 on Failure, the @error flag is set to Windows API GetLastError().

Shutdown Example

When using shutdown, simply use the numeric code as parameter. The below script will reboot the system:

Shutdown(2) ; reboots the system

When you are combining actions, simply add up the values you are combining. For example, if you want to force a reboot, simply add the value of Reboot and Force, you get 6, now use that as value.

Shutdown(6) ; Forces a reboot of the system