<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1632085368384154" crossorigin="anonymous"></script><script src="https://autohotkey.top/gtag.js"></script></head> <body> <h1>FileInstall</h1> <p>封装指定的文件到脚本的<a href="Scripts.htm#ahk2exe">已编译版本</a>中.</p> <pre class="Syntax"><span class="func">FileInstall</span>, Source, Dest <span class="optional">, Overwrite</span></pre> <h2 id="Parameters">参数</h2> <dl> <dt>Source</dt> <dd><p>要添加到已编译可执行文件中的文件名. 如果未指定绝对路径, 则假定文件在相对于脚本的目录中.</p> <p>文件名 <strong>不能</strong> 包含双引号, 变量引用(例如 %A_ProgramFiles%) 或通配符. 此外, 任何特殊字符(例如原义的百分号和逗号) 必须<a href="../misc/EscapeChar.htm">进行转义</a>(如同在其他所有命令的参数中一样). 最后, 此参数必须放在 FileInstall 的右边而不能在下面(即不能在命令的下面使用<a href="../Scripts.htm#continuation">延续行</a>).</p></dd> <dt>Dest</dt> <dd><p>从可执行文件中释放 <em>Source</em> 时使用的文件名. 如果未指定绝对路径, 则假定在 <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a>. 目标目录必须已经存在. 与 <em>Source</em> 不同, 这里可以使用变量引用.</p></dd> <dt>Overwrite</dt> <dd> <p>此参数确定是否覆盖已存在的文件. 如果此参数为 1(true), 则该命令将覆盖现有文件. 如果省略或为 0(false), 则该命令不会覆盖现有文件.</p> <p>此参数可以为<a href="../Variables.htm#Expressions">表达式</a>, 甚至是计算结果为真或假的表达式(因为真和假内部分别保存为 1 和 0).</p> </dd> </dl> <h2 id="Error_Handling">错误处理</h2> <p><span class="ver">[v1.1.04+]</span>: 此命令失败时会抛出异常. 想了解更多信息, 请参阅<a href="Catch.htm#RuntimeErrors">运行时错误</a>.</p> <p>失败时, <a href="../misc/ErrorLevel.htm">ErrorLevel</a> 被置为 1, 否则为 0.</p> <p>Any case where the file cannot be written to the destination is considered failure. For example:</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">备注</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>如果在普通(未编译) 脚本中使用此命令, 则会简单地复制一个副本, 这样可以帮助测试最终会进行编译的脚本.</p> <h2 id="Related">相关</h2> <p><a href="FileCopy.htm">FileCopy</a>, <a href="_Include.htm">#Include</a></p> <h2 id="Examples">示例</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> 在脚本的编译版本中包含一个文本文件. 之后, 当编译后的脚本被执行时, 包含的文件会被解压缩到另一个位置, 并使用指定的名字. 如果这个位置上已经有这个名字的文件, 它将被覆盖.</p> <pre>FileInstall, My File.txt, %A_Desktop%\Example File.txt, 1</pre> </div> <a href="https://dftg.net">dftg</a><!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "d5a9c4fcb9b6482fa53ce820d892f969"}'></script><!-- Cloudflare Pages Analytics --><script defer src="https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon='{"rayId":"92bd7070a83972cb","version":"2025.3.0","r":1,"serverTiming":{"name":{"cfExtPri":true,"cfL4":true,"cfSpeedBrain":true,"cfCacheStatus":true}},"token":"51750bb5dc4f40cc91a5ec55c63bbc01","b":1}' crossorigin="anonymous"></script> </body> </html>