FileInstall

AutoHotkey

FileInstall

Includes the specified file inside the compiled version of the script.

FileInstall, Source, Dest [, Flag]

Parameters

Source

The name of the file to be added to the compiled EXE. The file is assumed to be in (or relative to) the script's own directory if an absolute path isn't specified.

The file name must not contain double quotes, variable references (e.g. %A_ProgramFiles%), or wildcards. In addition, any special characters such as literal percent signs and commas must be escaped (just like in the parameters of all other commands). Finally, this parameter must be listed to the right of the FileInstall command (that is, not on a continuation line beneath it).

Dest

When Source is extracted from the EXE, this is the name of the file to be created. It is assumed to be in %A_WorkingDir% if an absolute path isn't specified. The destination directory must already exist. Unlike Source, variable references may be used.

Flag

(optional) this flag determines whether to overwrite files if they already exist:

0 = (default) do not overwrite existing files
1 = overwrite existing files

This parameter can be an expression, even one that evalutes to true or false (since true and false are stored internally as 1 and 0).

ErrorLevel

[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

Remarks

This command is a directive for the Ahk2Exe compiler that allows you to add extra files to the resulting compiled script. Later, when the compiled script is run, the files are extracted back out onto the disk.

The file is added during script compilation. When the compiled script is executed and the same "FileInstall" command is reached, the file is then extracted to Dest.

Files added to a script are compressed and also encrypted.

If this command is used in an normal (uncompiled) script, a simple file copy will be performed instead -- this helps the testing of scripts that will eventually be compiled.

Related

FileCopy, #Include

Example

FileInstall, C:\My Documents\My File.txt, %A_ProgramFiles%\My Application\Readme.txt, 1