Script Compiler (Ahk2Exe) Directives [v1.1.??+]

The script compiler accepts certain directives that allow you to further customize the compiled script (.exe).

Directives that control the script behaviour

It is possible to remove code sections from the compiled script by wrapping them in directives:

MsgBox This message appears in both the compiled and uncompiled script
MsgBox This message does NOT appear in the compiled script
MsgBox This message appears in both the compiled and uncompiled script

The reverse is also possible, i.e. marking a code section to only be executed in the compiled script:

MsgBox This message appears only in the compiled script
MsgBox This message appears in both the compiled and uncompiled script

This has advantage over A_IsCompiled because the code is completely removed from the compiled script during preprocessing, thus making the compiled script smaller. The reverse is also true: it will not be necessary to check for A_IsCompiled because the code is inside a comment block in the uncompiled script.

Directives that control executable metadata

In the parameters of these directives, the following escape sequences are supported: ``, `,, `n, `r and `t. Commas always need to be escaped, regardless of the parameter position. "Integer" refers to unsigned 16-bit integers (0..0xFFFF).


Changes a property in the compiled executable's version information.

;@Ahk2Exe-SetProp Value
PropThe name of the property to change. Must be one of below.
ValueThe value to set the property to.

The following properties are supported:

NameChanges the product name and the internal name.
DescriptionChanges the file description.
VersionChanges the file version, the product version, in both text and raw binary format. Ahk2Exe fills the binary version fields with the period-delimited numbers (up to four) that may appear at the beginning of the version text. Unfilled fields are set to zero. For example, 1.3-alpha would produce a binary version number of If this property is not modified, it defaults to the AutoHotkey version used to compile the script.
CopyrightChanges the legal copyright information.
OrigFilenameChanges the original filename information.
CompanyNameChanges the company name.


Overrides the custom EXE icon used for compilation.

;@Ahk2Exe-SetMainIcon [IcoFile]
IcoFile(Optional) The icon file to use. If omitted, the default AutoHotkey icon is used.


Specifies a command to be executed after a successful compilation.

;@Ahk2Exe-PostExec Command
CommandThe command to execute.


When a custom icon is specified, the presence of this directive reenables the usage of the separate Tray icon resource (which can then be replaced with something custom).



Changes the executable subsystem to Console mode.



Adds a resource to the compiled executable.

;@Ahk2Exe-AddResource FileName [, ResourceName]
FileNameThe filename of the resource to add. The type of the resource (as an integer or string) can be explicitly specified prepending an asterisk to it: *type Filename. If omitted, Ahk2Exe automatically detects the type according to the file extension.
ResourceName(Optional) The name that the resource will have (can be a string or an integer). If omitted, it defaults to the name (with no path) of the file, in uppercase.

Here is a list of common standard resource types and the extensions that trigger them by default.


Changes the resource language used by @Ahk2Exe-AddResource.

;@Ahk2Exe-UseResourceLang LangCode
LangCodeThe language code. Please note that hexadecimal numbers must have an 0x prefix.

The default resource language is US English (0x0409).