</head> <body> <h1>FileInstall</h1> <p>Includes the specified file inside the <a href="../Scripts.htm#ahk2exe">compiled version</a> of the script.</p> <pre class="Syntax"><span class="func">FileInstall</span>, Source, Dest <span class="optional">, Overwrite</span></pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>Source</dt> <dd><p>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.</p> <p>The file name <strong>must not</strong> 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 <a href="../misc/EscapeChar.htm">escaped</a> (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 <a href="../Scripts.htm#continuation">continuation line</a> beneath it).</p></dd> <dt>Dest</dt> <dd><p>When <em>Source</em> is extracted from the EXE, this is the name of the file to be created. It is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. The destination directory must already exist. Unlike <em>Source</em>, variable references may be used.</p></dd> <dt>Overwrite</dt> <dd> <p>This parameter determines whether to overwrite files if they already exist. If this parameter is 1 (true), the command overwrites existing files. If omitted or 0 (false), the command does not overwrite existing files.</p> <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>, even one that evalutes to true or false (since true and false are stored internally as 1 and 0).</p> </dd> </dl> <h2 id="Error_Handling">Error Handling</h2> <p><span class="ver">[v1.1.04+]</span>: This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p> <p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 on failure or 0 on success.</p> <p>Any case where the file cannot be written to the destination is considered failure. Por exemplo:</p> <ul> <li>The destination file already exists and the <em>Overwrite</em> parameter was 0 (false) or omitted.</li> <li>The destination file could not be opened due to a permission error, or because the file is in use.</li> <li>The destination path was invalid or specifies a folder which does not exist.</li> <li>The source file does not exist (only for uncompiled scripts).</li> <li>Source and destination are the same location (only for uncompiled scripts).</li> </ul> <h2 id="Remarks">Remarks</h2> <p>When this command is read by <a href="../Scripts.htm#ahk2exe">Ahk2Exe</a> during compilation of the script, the file specified by <em>Source</em> is added to the resulting compiled script. Later, when the compiled script EXE runs and the call to FileInstall is executed, the file is extracted from the EXE and written to the location specified by <em>Dest</em>.</p> <p>Files added to a script are neither compressed nor encrypted during compilation, but the compiled script EXE can be compressed by using the appropriate option in Ahk2Exe.</p> <p>If this command is used in a normal (uncompiled) script, a simple file copy will be performed instead -- this helps the testing of scripts that will eventually be compiled.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="FileCopy.htm">FileCopy</a>, <a href="_Include.htm">#Include</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Includes a text file inside the compiled version of the script. Later, when the compiled script is executed, the included file is extracted to another location with another name. If a file with this name already exists at this location, it will be overwritten.</p> <pre>FileInstall, My File.txt, %A_Desktop%\Example File.txt, 1</pre> </div> </body> </html>