[英]Inno Setup: Install other installer and run it before continuing my install
到目前为止,这是我代码的 [Files] 部分:
[Files]
Source: "other_installer.exe"; DestDir: "{app}"
Source: "myprogram.exe"; DestDir: "{app}"
Source: "data.dat"; DestDir: "{app}"
Source: "otherdata.dat"; DestDir: "{app}"
我的程序依赖于另一个程序来运行。 我已经在我的安装程序中包含了这个程序的安装程序(“other_installer.exe”)。 我想要做的是在复制后立即启动此安装程序,然后继续“myprogram.exe”和其余部分。
我在 Inno Setup Help 中搜索并找到了 BeforeInstall 的文档,但他们没有运行其他应用程序的示例。 我相信它应该是这样的:
[Files]
Source: "other_installer.exe"; DestDir: "{app}"
Source: "myprogram.exe"; DestDir: "{app}"; BeforeInstall: // RUN OTHER_INSTALLER.EXE //
Source: "data.dat"; DestDir: "{app}"
Source: "otherdata.dat"; DestDir: "{app}"
更好的方式可能是AfterInstall
参数。 以下脚本将在处理OtherInstaller.exe
文件条目后OtherInstaller.exe
执行RunOtherInstaller
函数。 在那里它会尝试执行刚刚安装的OtherInstaller.exe
文件,如果失败,它会向用户报告一条错误消息。 请注意,您无法从该功能中断安装,因此以这种方式执行您想要的操作并不安全:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "OtherInstaller.exe"; DestDir: "{app}"; AfterInstall: RunOtherInstaller
Source: "OtherFile.dll"; DestDir: "{app}"
[Code]
procedure RunOtherInstaller;
var
ResultCode: Integer;
begin
if not Exec(ExpandConstant('{app}\OtherInstaller.exe'), '', '', SW_SHOWNORMAL,
ewWaitUntilTerminated, ResultCode)
then
MsgBox('Other installer failed to run!' + #13#10 +
SysErrorMessage(ResultCode), mbError, MB_OK);
end;
另一个运行先决条件安装程序的好时机是在PrepareToInstall
事件函数中。 (有关基本结构,请参阅 Inno 提供的示例脚本,以及实际执行的 TLama 代码。)
PrepareToInstall
的主要优点是它允许您处理来自子安装程序的错误和重新启动请求——而使用AfterInstall
则不然。
它的主要缺点是您必须手动ExtractTemporaryFile
运行子安装所需的任何内容,因为这是在提取文件之前发生的。
您可以使用 AfterInstall,在帮助中查找。 刚刚复制文件时,我将启动您放置为“AfterInstall:”的功能/过程。
在此功能/过程中,使用 Exec 并启动其他安装程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.