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 or wildcards. In addition, this parameter must be listed to the right of the FileInstall function (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.

Flag

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

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

ErrorLevel

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

Remarks

This function 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" function is reached, the file is then extracted to Dest.

Files added to a script are compressed and also encrypted.

If this function 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