Keyword Reference


Exit

Terminates the script.

Exit [return code]

Parameters

return code [optional] Integer that sets the script's return code. This code can be used by Windows or the DOS variable %ERRORLEVEL%. The default is 0. Scripts normally set an errorlevel of 0 if the script executed properly; error levels 1 and above typically indicate that the script did not execute properly.

Remarks

The parameter, if included, can be enclosed in parentheses. Thus, the following are equivalent: Exit, Exit 0, and Exit(0). However, Exit() is invalid.

The code can be retrieved in an OnAutoItExitRegister function by @exitCode.

Related

ExitLoop, OnAutoItExitRegister

Example

Example 1

; very simple script

Exit

Example 2

; Terminate script if no command-line arguments
If $CmdLine[0] = 0 Then Exit (1)