Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup: How to manipulate progress bar on Run section?

Similar to this question:
How to set the progress bar value in the [Run] section of the Inno Setup install script?

When the Inno Setup gets to the [Run] section, the progress bar shows at 100% and stops in this position.

I have many files that I install in this Run section, which I wish to restart the progress bar and control it, as it goes installing each program.

The status message is easy to change (StatusMsg), but the progress I'm missing something. Could you guys help me out, please?

Example:

[Run]
Filename: "msiexec.exe"; Parameters: "/i ""msxml.msi"" /quiet"; \
    StatusMsg: "MSXML..."; Flags: runascurrentuser
Filename: "msiexec.exe"; Parameters: "/i ""capicom_dc_sdk.msi"" /quiet"; \
    StatusMsg: "CAPICOM..."; Flags: runascurrentuser

Since I want to control the progress bar during it's installation, I don't know what to do. I thought in maybe using BeforeInstall parameter, creating a code to set the progress bar to 0 by doing something like WizardForm.ProgressGauge.Position = 0; and in the AfterInstall parameter, the opposite, WizardForm.ProgressGauge.Position = 100;, but how to change during the installation?

Thanks.

like image 489
KurayamiArai Avatar asked Dec 17 '15 14:12

KurayamiArai


People also ask

How do I change the icon on my Inno?

As you know the application icon is built into the .exe file. The Inno Setup cannot modify the .exe files. And there's no other way to override the application icon by an external one. You have to edit the .exe file yourself, before building the installer.

How do I add a checkbox in Inno?

You don't have to manually create checkboxes for that. The standard way to let the user choose what to install is to use the [Types] and [Components] sections of your script file. Take a look at the Components. iss script located in your Inno Setup install folder\examples.

How do I make an inno file executable?

Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.


1 Answers

It would be rather difficult to update the progress bar, while another process is running.

I do not see a point of endeavoring it, as you are unlikely able to tell the progress of the sub-installer, so you won't know what to update the progress bar to.

Except for special cases, when the sub-installer provides an API to report its progress.
For an example, see:

  • Inno Setup Get progress from .NET Framework 4.5 (or higher) installer to update progress bar position or
  • Make Inno Setup Installer report its installation progress status to master installer.

To update the progress bar according to number of sub-installers finished, you can do:

[Run]
FileName: "process1"; BeforeInstall: UpdateProgress(0); \
    AfterInstall: UpdateProgress(33)
FileName: "process2"; AfterInstall: UpdateProgress(66)
FileName: "process3"; AfterInstall: UpdateProgress(100)

[Code]

procedure UpdateProgress(Position: Integer);
begin
  WizardForm.ProgressGauge.Position :=
    Position * WizardForm.ProgressGauge.Max div 100;
end;

To divide part of the progress range for installing files and the rest to running the sub-installers, see
Inno Setup - Prevent extraction of files from setting progress bar to 100%


Another option is to use a "marquee" (= infinite) progress bar style.

See Progress bar control styles.

[Run]
FileName: "process1"; BeforeInstall: SetMarqueeProgress(True)
FileName: "process2"
FileName: "process3"; AfterInstall: SetMarqueeProgress(False)

[Code]

procedure SetMarqueeProgress(Marquee: Boolean);
begin
  if Marquee then
  begin
    WizardForm.ProgressGauge.Style := npbstMarquee;
  end
    else
  begin
    WizardForm.ProgressGauge.Style := npbstNormal;
  end;
end;

enter image description here

Works even on Windows XP, despite not being listed in the official Microsoft documentation anymore. Tested on Windows XP SP3.

enter image description here

like image 192
Martin Prikryl Avatar answered Sep 26 '22 03:09

Martin Prikryl