Inno Setup:在继续我的安装之前安装其他安装程序并运行它 [英] Inno Setup: Install other installer and run it before continuing my install

查看:69
本文介绍了Inno Setup:在继续我的安装之前安装其他安装程序并运行它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我目前代码的 [Files] 部分:

This is the [Files] portion of my code so far:

[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"和其余部分.

My program is dependent on another program to run. I've included the installer for this program ("other_installer.exe") in my installer. What I would like to do is launch this installer as soon as it has been copied, before continuing with "myprogram.exe" and the rest.

我在 Inno Setup Help 中搜索并找到了 BeforeInstall 的文档,但他们没有运行其他应用程序的示例.我相信它应该是这样的:

I've googled and found the documentation for BeforeInstall in the Inno Setup Help, but they don't have an example of running another application. I believe it should be something like this:

[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 文件条目后立即执行 RunOtherInstaller 函数.在那里它会尝试执行刚刚安装的 OtherInstaller.exe 文件,如果失败,它会向用户报告错误消息.请注意,您无法通过该功能中断安装,因此以这种方式执行您想要的操作并不安全:

Better for the way you go might be the AfterInstall parameter. The following script will execute the RunOtherInstaller function right after the OtherInstaller.exe file entry is processed. There it tries to execute the just installed OtherInstaller.exe file and if that fails, it reports an error message to the user. Please note that you cannot interrupt the installation from that function, so it's not much safe to do what you want this way:

[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;

这篇关于Inno Setup:在继续我的安装之前安装其他安装程序并运行它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆