4

This is similar to this question: Inno Setup Simple progress page for Run section

If I'm adding some MSI files to my Inno Setup script, I can install these files from the [Run] section. At that time the progress bar shows 100% and shows the StatusMsg above the progress bar.

I want manually set the value of the progress bar in the [Run] section, say a value of 50%.

Similar to something like this:

[Run]
Filename: msiexec.exe; Parameters: "/i ""{#MyRtePath}\runtime.msi"" /qn /norestart"; \
    StatusMsg: Installing Runtime Engine; WizardForm.ProgressGauge.progress: 50 ;
Community
  • 1
  • 1
SamuelJames84
  • 277
  • 4
  • 10

2 Answers2

3

You can use similar code to the question you linked to, by calling it from the BeforeInstall and/or AfterInstall handler for each [Run] entry. Note that Inno itself will run up to 100% in the files section, so you're code will need to start from 0% again, or adjust EVERY entry to use the custom positioning.

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • Thanks for your response. I can't understand what you are trying to convey. Can u provide a sample code..? – SamuelJames84 Dec 19 '11 at 03:09
  • No I can't, beyond the help file. Simply put, the progress bar goes from 0 to 100%, then the `[Run]` entries are processed so it has to start again from 0% and increment for each entry, by calling the code fromthe `AfterInstall` parameter. – Deanna Dec 19 '11 at 08:44
1

Late response, but here is some example code I made for anyone else looking for an answer.

Above the [Setup] section you will need to define a constant named AppName for use later, you can also use it to set your Setup AppName variable.

#define AppName "Test Installer"
[Setup]
AppName={#AppName}

Now down in your [code] section you will need to add the following.

[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;

Now you can call the DisplayInstallProgress and UpdateInstallProgress procedures in the [Run] section using the BeforeInstall and AfterInstall Parameters, like below.

[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, '');

I had used this question/answer as a template for creating the progress page: How to show progress during “PrepareToInstall”?

Final note, this implementation goes against jrsoftware's advice:

Always put the Hide call inside the finally part of a try..finally language construct, as demonstrated in CodeDlg.iss. Not calling Hide will result in the wizard being permanently stuck on the progress page.

However I couldn't figure out a way of implementing progress accross items in the [run] section without doing this.

Community
  • 1
  • 1
  • Maybe you should explain, that your code actually creates a new progress page. Instead of manipulating the progress bar on the standard "installing" page, what the question asked for. – Martin Prikryl Jul 09 '16 at 05:26