简体   繁体   English

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

[英]Inno Setup: Install other installer and run it before continuing my install

This is the [Files] portion of my code so far:到目前为止,这是我代码的 [Files] 部分:

[Files]
Source: "other_installer.exe"; DestDir: "{app}"
Source: "myprogram.exe"; DestDir: "{app}"
Source: "data.dat"; DestDir: "{app}"
Source: "otherdata.dat"; DestDir: "{app}"

My program is dependent on another program to run.我的程序依赖于另一个程序来运行。 I've included the installer for this program ("other_installer.exe") in my installer.我已经在我的安装程序中包含了这个程序的安装程序(“other_installer.exe”)。 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.我想要做的是在复制后立即启动此安装程序,然后继续“myprogram.exe”和其余部分。

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.我在 Inno Setup Help 中搜索并找到了 BeforeInstall 的文档,但他们没有运行其他应用程序的示例。 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}"

Better for the way you go might be the AfterInstall parameter.更好的方式可能是AfterInstall参数。 The following script will execute the RunOtherInstaller function right after the OtherInstaller.exe file entry is processed.以下脚本将在处理OtherInstaller.exe文件条目后OtherInstaller.exe执行RunOtherInstaller函数。 There it tries to execute the just installed OtherInstaller.exe file and if that fails, it reports an error message to the user.在那里它会尝试执行刚刚安装的OtherInstaller.exe文件,如果失败,它会向用户报告一条错误消息。 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;

Another good time to run prerequisite installers is in the PrepareToInstall event function.另一个运行先决条件安装程序的好时机是在PrepareToInstall事件函数中。 (See the example scripts provided with Inno for the basic structure, and TLama's code for the actual execution.) (有关基本结构,请参阅 Inno 提供的示例脚本,以及实际执行的 TLama 代码。)

The main advantage of PrepareToInstall is that it allows you to handle errors and reboot requests from the child installer -- using AfterInstall doesn't. PrepareToInstall的主要优点是它允许您处理来自子安装程序的错误和重新启动请求——而使用AfterInstall则不然。

The main disadvantage of it is that you have to manually ExtractTemporaryFile anything required to run the child install, as this occurs prior to files being extracted.它的主要缺点是您必须手动ExtractTemporaryFile运行子安装所需的任何内容,因为这是在提取文件之前发生的。

You can use AfterInstall, look for this in the Help.您可以使用 AfterInstall,在帮助中查找。 When file is just copied, i'll launch the function/procedure you put as "AfterInstall:".刚刚复制文件时,我将启动您放置为“AfterInstall:”的功能/过程。

In this function/procedure, use Exec and launch the other installer.在此功能/过程中,使用 Exec 并启动其他安装程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM