inno-setup – 在Inno安装程序中,可以添加条件语句到[Run]部分中执行什么?

前端之家收集整理的这篇文章主要介绍了inno-setup – 在Inno安装程序中,可以添加条件语句到[Run]部分中执行什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
或者也可以手动更新内置进度条?
基本上我有2个MSI,并且使用Inno Setup作为引导程序,根据用户输入,要安装一个或两个MSI.我有一些使用CurstepChanged中的Exec语句的工作,但它不会更新进度条,因为文件提取,看起来像安装程序停滞.我想最终的结果是我想要一些进度条更新,而文件提取到临时文件夹.以下是我当前的代码
procedure CurStepChanged(CurStep: TSetupStep);
var
    ResultCode: Integer;
begin
    if(CurStep = ssInstall) then begin
        if(InstallServer) then begin
            ExtractTemporaryFile('ServerSetup.msi');
            Exec('msiexec',ExpandConstant('/i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2'),'',SW_SHOW,ewWaitUntilTerminated,ResultCode);
        end;
        if(InstallClient) then begin
            ExtractTemporaryFile('ClientSetup.msi');
            Exec('msiexec',ExpandConstant('/i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2'),ResultCode);
        end;
    end;
end;

解决方法

为什么不简单地尝试这样的事情:
[Files]
Source: ClientSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Components: Client
Source: ServerSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Components: Server

[Run]
Filename: msiexec.exe; Parameters: /i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing client; Components: Client
Filename: msiexec.exe; Parameters: /i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing server; Components: Server

[Components]
Name: Client; Description: Client Installation
Name: Server; Description: Server Installation

当然,您不一定要使用组件.您没有写出如何决定要运行哪个安装程序.如果您需要更复杂的逻辑,您还可以使用Check functions,如:

[Files]
Source: ClientSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Check: CheckClient
Source: ServerSetup.msi; DestDir: {tmp}; Flags: deleteafterinstall; Check: CheckServer

[Run]
Filename: msiexec.exe; Parameters: /i "{tmp}\ClientSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Client\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing client; Check: CheckClient
Filename: msiexec.exe; Parameters: /i "{tmp}\ServerSetup.msi" /qb INSTALLDIR="{code:GetInstallPath}\Server\" ALLUSERS=2; WorkingDir: {tmp}; StatusMsg: Installing server; Check: CheckServer

[Code]
function CheckClient: Boolean;
begin
  Result := WhateverCondition;
end;

function CheckServer: Boolean;
begin
  Result := WhateverOtherCondition;
end;

猜你在找的Delphi相关文章