1

I would like to know how to add a checkbox before completing the installation. The checkbox will ask the user if they want to download and install a second system. It should appear on a screen after all scripts and installation steps have been accepted. When checked setup should download another installer via HTTP and then install the downloaded application.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Mylon
  • 115
  • 1
  • 2
  • 8

1 Answers1

4

You can create a custom options page (CreateInputOptionPage) after the installation page (wpInstalling).

And use Inno Setup 6.1 has built-in support for downloads or Inno Download Plugin to trigger the downloaded, if the users choose so.

The code below uses Inno Download Plugin, but nowadays you should use Inno Setup built-in support for downloads. See Inno Setup: Install file from Internet.

After the download, e.g. when the "Completing" page (wpFinished) shows, execute the downloaded application.

[Code]

#include "idp.iss"

var
  DownloadOptionPage: TInputOptionWizardPage;

procedure InitializeWizard();
begin
  DownloadOptionPage :=
    CreateInputOptionPage(wpInstalling,
      'Additional download',
      'Select what additional components do you want to download and install.',
      '', False, False);
  DownloadOptionPage.Add('Something');
  idpDownloadAfter(DownloadOptionPage.ID);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;

  if CurPageID = DownloadOptionPage.ID then
  begin
    if DownloadOptionPage.Values[0] then
    begin
      idpAddFile(
        'https://www.example.com/something.exe',
        ExpandConstant('{tmp}\something.exe'));
    end;
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
var
  FileName: string;
  ResultCode: Integer;
begin
  if CurPageID = wpFinished then
  begin
    FileName := ExpandConstant('{tmp}\something.exe');
    if FileExists(FileName) then
    begin
      if not Exec(FileName, '', '', SW_SHOW, ewNoWait, ResultCode) then
      begin
        MsgBox(Format('Error executing %s', [FileName]), mbError, MB_OK);
      end;
    end;
  end;
end;

Download options page

Download page


Though neither Inno Setup nor the Download Plugin are not really designed to do anything after the installation is finished. For example the "Cancel" button is hidden, so you cannot cancel the download. And what's worse, you cannot exit the installer, if the download fails for whatever reason.

It could probably be worked around.

But you may consider instead to use the standard workflow, where all user options are gathered and dependencies are downloaded before the installation.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992