在Inno Setup中,可以将条件语句添加到要执行的[Run]部分中的内容上吗? [英] In Inno Setup is it possible to add conditional statements to what in the [Run] section gets executed?
问题描述
或者可以手动更新内置进度条吗? 基本上,我包括2个MSI,并且使用Inno Setup作为引导程序,并且要根据用户输入安装一个或两个MSI.我在CurStepChanged中使用Exec语句有一些工作,但是由于提取了文件,它并没有更新进度条,并且看起来安装程序已停止.我猜最终结果是我希望一些进度条更新,同时将文件提取到temp文件夹中.以下是我当前的代码:
Alternatively is it possible to manually update the built in progress bar? Basically I have 2 MSIs included and using Inno Setup as a bootstrapper, and depending on user input one or both of the MSIs are to be installed. I have something working using Exec statements in CurStepChanged but it doesn't update the progress bar as the files are extracted and it looks like the installer is stalled. I guess the end result is I want some progress bar updates while the files are extracted to the temp folder. The following is my current code:
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'),'', SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
end;
end;
推荐答案
为什么不简单尝试这样的事情:
Why not simply try something like this:
[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
当然,您不一定必须使用Components
.您没有编写如何决定运行哪个安装程序的信息.如果您需要更复杂的逻辑,也可以使用 Check
函数,如下所示:>
Of course you don't necessarily have to use Components
. You did not write how you decide which installer to run. If you need more complex logic you could also use Check
functions as in:
[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;
这篇关于在Inno Setup中,可以将条件语句添加到要执行的[Run]部分中的内容上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!