FileInstall

封装指定的文件到脚本的已编译版本中.

FileInstall, Source, Dest , Overwrite

参数

Source

要添加到已编译可执行文件中的文件名. 如果未指定绝对路径, 则假定文件在相对于脚本的目录中.

文件名 不能 包含双引号, 变量引用(例如 %A_ProgramFiles%) 或通配符. 此外, 任何特殊字符(例如原义的百分号和逗号) 必须进行转义(如同在其他所有命令的参数中一样). 最后, 此参数必须放在 FileInstall 的右边而不能在下面(即不能在命令的下面使用延续行).

Dest

从可执行文件中释放 Source 时使用的文件名. 如果未指定绝对路径, 则假定在 %A_WorkingDir%. 目标目录必须已经存在. 与 Source 不同, 这里可以使用变量引用.

Overwrite

此参数确定是否覆盖已存在的文件. 如果此参数为 1(true), 则该命令将覆盖现有文件. 如果省略或为 0(false), 则该命令不会覆盖现有文件.

此参数可以为表达式, 甚至是计算结果为真或假的表达式(因为真和假内部分别保存为 1 和 0).

错误处理

[v1.1.04+]: 此命令失败时会抛出异常. 想了解更多信息, 请参阅运行时错误.

失败时, ErrorLevel 被置为 1, 否则为 0.

Any case where the file cannot be written to the destination is considered failure. For example:

备注

When this command is read by Ahk2Exe during compilation of the script, the file specified by Source 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 Dest.

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.

如果在普通(未编译) 脚本中使用此命令, 则会简单地复制一个副本, 这样可以帮助测试最终会进行编译的脚本.

FileCopy, #Include

示例

在脚本的编译版本中包含一个文本文件. 之后, 当编译后的脚本被执行时, 包含的文件会被解压缩到另一个位置, 并使用指定的名字. 如果这个位置上已经有这个名字的文件, 它将被覆盖.

FileInstall, My File.txt, %A_Desktop%\Example File.txt, 1
unixetc