Installation Inno安装程序:安装其他安装程序并在继续安装之前运行它

Installation Inno安装程序:安装其他安装程序并在继续安装之前运行它,installation,inno-setup,Installation,Inno Setup,这是到目前为止我的代码的[文件]部分: [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”)包

这是到目前为止我的代码的[文件]部分:

[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安装帮助中搜索并找到了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}"

更好的方法可能是参数。以下脚本将在处理
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;

您可以使用AfterInstall,请在帮助中查找。 当文件刚被复制时,我将启动您设置为“AfterInstall:”的函数/过程


在此函数/过程中,使用Exec并启动其他安装程序。

运行必备安装程序的另一个好时机是在
preparetoall
事件函数中。(请参阅Inno提供的示例脚本了解基本结构,以及TLama的代码了解实际执行情况。)

PrepareToInstall
的主要优点是,它允许您处理来自子安装程序的错误和重新启动请求,而使用
AfterInstall
则不会


它的主要缺点是,您必须手动
ExtractTemporaryFile
运行子安装所需的任何内容,因为这发生在提取文件之前。

是的,如果我的答案与您的答案相似,我很抱歉。是否可以存储错误和中断(并可能回滚)后来安装了吗?我试过了,虽然我得到了错误:“请求需要提升”。请问我该怎么办?它很有魅力。但是,如何处理不可执行文件?我试图打开一个
p12
certificate文件,它向我抛出错误:
%1不是有效的win32应用程序