Compiling Scripts with Aut2Exe

It is possible to take your .au3 script and compile it into a standalone executable; this executable can be used without the need for AutoIt to be installed and without the need to have AutoIt3.exe on the machine. The compilation process converts the script and its #include files, plus any files added by the FileInstall function, into a tokenised form which is then compressed and encrypted. In that way none of these additional files are required at runtime. Depending on the compilation option chosen, this "compiled" script will either be inserted into the resources of a stand-alone executable interpreter which will run it directly or saved in .a3x format. An .a3x file can be included in another script or run by an AutoIt interpreter - either Autoit3.exe itself or another compiled script with the AutoItExecuteAllowed flag set.

Caution: the script to be compiled must be free of syntax error as the compilation process does not check the syntax.

 

Aut2Exe can be used in three ways:

Method 1 - Start Menu

Only available if full install performed.

1.  Open the Start Menu and browse to the AutoIt v3 group.

2.  Click Compile Script to .exe

3.  The main Aut2Exe interface should appear.

       

4.  Use the Browse buttons to select your input (.au3) and output (.exe) files.

5.  If you like you can change the icon of the resulting .exe - just browse to the icon you want (some example icons are supplied in Program Files\AutoIt3\Aut2Exe\Icons).

6.  The only other option you might wish to change is the compression level (especially if using FileInstall to add extra files). Use the Compression menu to set this. As with all compression routines the better the compression you select the slower it will be. However, no matter what compression level you select the decompression speed (when the .exe is run) is the same.

7.  Click on Convert to compile the script.

Note: Scripts can be compiled with .a3x extension. They should be run with AutoIt.exe filename.a3x. The .a3x contains the script itself with all referred #include plus the FileInstall files. This format allows you to distribute smaller files as they don't include the AutoIt3.exe in each compiled script. You still need to have it accessible on the target machine but just AutoIt3.exe.

 

Method 2 - Right Click

Only available if full install performed.

1.  In Explorer browse to the .au3 file that you wish to compile.

2.  Right-click the file to access the pop-up menu.

       

3.  The file will be silently compiled with the same filename - just with a .exe extension.

When compiling in this way, Aut2Exe uses current icon/compression settings (from the last time Aut2Exe was run manually as in method 1).

 

Method 3 - The Command Line

The Aut2Exe.exe program can be run from the command line as follows:

    Aut2exe.exe /in <infile.au3> [/out <outfile.exe>] [/icon <iconfile.ico>] [/comp 0-4] [/nopack] [/x64] [/bin <binfile.bin>]

Where

Switch Usage Default value
/in <infile.au3> Specifies the path and file name of the bin file to be used to compile the file. None. The file must be specified
/out <outfile.exe> Specifies the path and name of the compiled file.
<outfile.a3x> Specifies the path and file name when creating an *.a3x file.
The input filename with a .exe extension
/icon <iconfile.ico> Specifies the path and file name of the icon to use for the compiled file. Default icon
/comp Specifies the compression level to be used when encoding the script (This is NOT related to UPX).
It must be a number between 0 (none) and 4 (maximum).
2
/nopack Specifies that the file should not be compressed with UPX after compilation. pack
/pack Specifies that the file should be compressed with UPX after compilation. pack
/x64 Specifies that the script should be compiled for use on systems with x64 (64-bit) architecture. see notes
/x86 Specifies that the script should be compiled for use on systems with x86 (32-bit) architecture. see notes
/console Specifies that the script should be compiled as a Console application. Windows application (/gui)
/gui Specifies that the script should be compiled as a Windows application. Windows application (/gui)

Command Line Examples

/in c:\myscript.au3 /out c:\myapp.exe /icon c:\myicon.ico /x64

Will result in the creation of c:\myapp.exe with normal compression which will use the specified icon and be compiled for use on x64 system architecture.

/in c:\myscript.au3

will result in the creation of a unicode c:\myscript.exe with normal compression which will use the default AutoIt icon for use on win_32 systems.

Command Line Notes

Long filenames should be enclosed in double-quotes like "C:\Program Files\Test\test.au3".

With the exception of /in all switches are optional.

By default, the 32-bit compiler produces a 32-bit binary and the 64-bit compiler produces a 64-bit binary. Use the /x86 and /x64 parameters to explicitly specify the output.

The /pass and /nodecompile switches are redundant as of version 3.2.8.1. They will be ignored if used and have been removed from this list.

The /ansi and /unicode switches are redundant as of version 3.3.0.0.

The /bin switch is redundant as of version 3.3.10.0 and has been removed from this list..

Technical Details

The compiled script and additional files added with FileInstall are compressed with my own (Jon) compression scheme.