当依赖项无法安装时中止安装 [英] Abort installation when dependency fails to install

查看:77
本文介绍了当依赖项无法安装时中止安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.msi文件和两个必备文件.根据我的代码,安装成功后,安装程序将从.msi文件执行主exe文件.但是,如果已经安装了早期版本的.msi文件,则它带有修复并删除选项.卸载.msi文件后,我的Run部分正在运行,并且在删除msi文件后我想退出该应用程序,否则它将不执行Run部分.有人可以建议我一些解决方案吗?

I have one .msi file and two prerequisites files. As per my code, the setup will execute main exe file from .msi file after successful installation. But if the previous version of .msi file is already installed, it coming with the option of Repair and Remove. My Run section is running after I uninstalled .msi file and I want to quit the application after it removed msi file or it will not execute the Run section. Can anyone please suggest me some solutions?

这是我的Run部分:

[Run]
Filename: "{app}\{#MyAppExeName}"; Parameters: "/verysilent /group=""{groupname}\Macrowire 2.5 Pro"" /mergetasks=""desktopicon,file_association"""; Flags: nowait postinstall; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; StatusMsg: "Installing Macrowire 2.5 Pro..."

这是我的Pascal代码:

Here is my Pascal code:

function PrepareToInstall(var NeedsRestart: Boolean): String;
var 
  ResultCode: integer;
begin
  ...
  if IsComponentSelected('Macrowire') or IsComponentSelected('Full') then
  begin
    ShellExec('', ExpandConstant('{app}\MacroWire 2.5 Pro.msi'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) 
  end;
  ...
end;

推荐答案

当依赖项无法安装时,您可能想中止安装:

You probably want to abort the installation when the dependency fails to install:

function PrepareToInstall(var NeedsRestart: Boolean): String;
var 
  ResultCode: integer;
begin
  ...
  if IsComponentSelected('Macrowire') or IsComponentSelected('Full') then
  begin
    { Using Exec, the ShellExec is an overkill }
    Exec(ExpandConstant('{app}\MacroWire 2.5 Pro.msi'), '', '', SW_SHOW,
         ewWaitUntilTerminated, ResultCode);
    if not FileExists(ExpandConstant('{app}\{#MyAppExeName}')) then
    begin
      Result := 'Failed to install MacroWire';
      Exit;
    end;
  end;
  ...
end;


如果要继续安装,但只需要跳过[Run]条目,请使用 Check参数:


If you want the installation to continue, but you just need to skip the [Run] entry, use the Check parameter:

[Run]
Filename: "{app}\{#MyAppExeName}"; Parameters: "..."; Flags: nowait postinstall; \
    Description: "..."; Check: FileExists(ExpandConstant('{app}\{#MyAppExeName}'))


顺便说一句,StatusMsg参数不适用于postinstall条目.而且我仍然不确定类似安装程序的Parameters是否与此程序相关.


Btw, the StatusMsg parameter is not used with postinstall entries. And I'm still not sure if the installer-like Parameters are relevant for this program.

这篇关于当依赖项无法安装时中止安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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