这与此问题类似: Inno Setup Simple progress page for Run section
如果我在我的Inno Setup脚本中添加了一些MSI文件,我可以从[Run]
部分安装这些文件。此时,进度条显示100%,并在进度条上方显示StatusMsg
。
我想手动设置[Run]
部分中进度条的值,比如说值为50%。
类似于以下内容:
[Run]
Filename: msiexec.exe; Parameters: "/i ""{#MyRtePath}\runtime.msi"" /qn /norestart"; \
StatusMsg: Installing Runtime Engine; WizardForm.ProgressGauge.progress: 50 ;
答案 0 :(得分:2)
您可以对链接到的问题使用类似的代码,方法是从每个BeforeInstall
条目的AfterInstall
和/或[Run]
处理程序中调用它。
请注意,Inno本身将在文件部分中运行高达100%,因此您的代码将需要再次从0%开始,或者调整每个条目以使用自定义定位。
答案 1 :(得分:1)
延迟回复,但这里是我为其他任何寻找答案的代码示例。
在# use tapply to get the sums. using with() makes the code nicer, IMO.
cat_sums <- with(df, tapply(quantity, category, sum))
# use lookup table to create new column
df$sum.category <- cat_sums[df$category]
# id category quantity sum.category
#1 1 AB 235 601
#2 2 BC 987 987
#3 3 AB 366 601
#4 4 CD 287 287
部分之上,您需要定义一个名为AppName的常量以供日后使用,您也可以使用它来设置您的Setup AppName变量。
[Setup]
现在,在#define AppName "Test Installer"
[Setup]
AppName={#AppName}
部分中,您需要添加以下内容。
[code]
现在,您可以使用BeforeInstall和AfterInstall参数调用[Code]
var
InstallWithProgressPage : TOutputProgressWizardPage;
//Create custom progress bar for install progress
procedure InitializeWizard;
var
UpdatedPageString: AnsiString;
OriginalPageString: String;
begin
//The string msgWizardPreparing has the macro '[name]' inside that we have to replace.
OriginalPageString := SetupMessage(msgPreparingDesc);
StringChange(OriginalPageString, '[name]', '{#AppName}');
UpdatedPageString := OriginalPageString;
InstallWithProgressPage := CreateOutputProgressPage(SetupMessage(msgWizardPreparing), UpdatedPageString);
end;
//Enable or Disable the install progress page (also set initial progress/text)
procedure DisplayInstallProgress(showPage:Boolean; progressText:String);
begin
if(showPage = True) then
begin
InstallWithProgressPage.Show;
InstallWithProgressPage.SetText(progressText, '');
InstallWithProgressPage.SetProgress(0,100);
end
else
begin
InstallWithProgressPage.Hide;
end
end;
//Update the install progress page
procedure UpdateInstallProgress(progressText:String; progressPercent:Integer);
begin
InstallWithProgressPage.SetProgress(progressPercent,100);
InstallWithProgressPage.SetText(progressText, '');
end;
部分中的DisplayInstallProgress和UpdateInstallProgress过程,如下所示。
[Run]
我曾将此问题/答案用作创建进度页面的模板:How to show progress during “PrepareToInstall”?
最后请注意,此实施违反了jrsoftware's advice:
始终将Hide调用放在try..finally语言结构的finally部分中,如CodeDlg.iss中所示。不调用隐藏将导致向导永久停留在进度页面上。
但是,如果不这样做,我无法找到一种在[Run]
FileName: "Powershell.exe"; Parameters: "-File {app}\Part1.ps1"; BeforeInstall: DisplayInstallProgress(True, 'Installing part 1.');
FileName: "Powershell.exe"; Parameters: "-File {app}\Part2.ps1"; BeforeInstall: UpdateInstallProgress('Installing part 2.', 30);
FileName: "Powershell.exe"; Parameters: "-File {app}\Part3.ps1"; BeforeInstall: UpdateInstallProgress('Installing part 3.', 60);
FileName: "Powershell.exe"; Parameters: "-File {app}\Part3.ps1"; BeforeInstall: UpdateInstallProgress('Installing part 4.',90); AfterInstall: DisplayInstallProgress(False, '');
部分中实现项目进展的方法。