Andrew Truckle
Andrew Truckle

Reputation: 19157

Adding post-install radio option to do nothing when installer has finished

Some time back I had this question. Some of that code is repeated here:

procedure RebuildRunList;
var
  RunEntries: array of TRunEntry;
  I: Integer;
begin
  { Save run list ... }
  SetArrayLength(RunEntries, WizardForm.RunList.Items.Count);
  for I := 0 to WizardForm.RunList.Items.Count - 1 do
  begin
    RunEntries[I].Caption := WizardForm.RunList.ItemCaption[I];
    RunEntries[I].Checked := WizardForm.RunList.Checked[I];
    RunEntries[I].Object := WizardForm.RunList.ItemObject[I];
  end;

  { ... clear it ... }
  WizardForm.RunList.Items.Clear;

  { ... and re-create }
  for I := 0 to GetArrayLength(RunEntries) - 1 do
  begin
    { the first two entries are radio buttons }
    if (I = 0) or (I = 1) then
    begin
      WizardForm.RunList.AddRadioButton(
        RunEntries[I].Caption, '', 0, RunEntries[I].Checked, True, RunEntries[I].Object);
    end
      else
    begin
      WizardForm.RunList.AddCheckBox(
        RunEntries[I].Caption, '', 0, RunEntries[I].Checked, True, True, True,
        RunEntries[I].Object);
    end;
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpFinished then
  begin
    { Only now is the RunList populated. }
    { Two entries are on 64-bit systems only. }
    if IsWin64 then RebuildRunList;
  end;
end;

I would like to know how I can make a enhancement to the radio choices. The drawback at the moment is that the user is forced to start one or the other application. I would like to add another radio option for simply closing down the installer. Ideally it would use a Inno Setup supplied message so that I do not have to ask for translations. (See this question).

Can this be done?

Upvotes: 1

Views: 157

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202474

The easiest solution is to add a no-op entry to the RunList:

[Run]
...
Filename: "{cmd}"; Parameters: "/C exit"; Description: "Exit setup";  \
    Flags: nowait postinstall runasoriginaluser unchecked skipifsilent runhidden; \
    Check: IsWin64

And turn it to a radio button:

    { the first three entries are radio buttons }
    if (I = 0) or (I = 1) or (I = 2) then

Upvotes: 2

Related Questions