1
votes

How can I have file1.exe, file2.exe and file3.exe wrapped in a single setup file using Inno so that the file# of choice is launched when user selects its associated radio button?

Please see the complete script I'm trying to make work. Since there is no Check flag on [Files] or any kind of procedure and listeners, upon clicking Next - all 3 files launch one after another.

===

[Setup]   
CreateAppDir=no   
OutputDir=C:\Single-Exe   
OutputBaseFilename=setup   
Compression=lzma   
SolidCompression=yes   
DisableWelcomePage=True   
DisableReadyPage=True   
DisableFinishedPage=True   
Uninstallable=no

[Languages]
Name: english; MessagesFile: compiler:Default.isl

[Files]
Source: file1.exe; DestDir: {app};
Source: file2.exe; DestDir: {app};
Source: file3.exe; DestDir: {app};

[Run]
Filename: {app}\file1.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}
Filename: {app}\file2.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}
Filename: {app}\file3.exe; Flags: hidewizard runhidden 64bit; WorkingDir: {localappdata}

[Code]
const
  FileOneDesc =
    'Select if you want to run File1.exe';
  FileTwoDesc =
    'Select if you want to run File2.exe';
  FileThreeDesc =
    'Select if you want to run File3.exe';

var
  FileOneButton: TNewRadioButton;
  FileTwoButton: TNewRadioButton;
  FileThreeButton: TNewRadioButton;

procedure InitializeWizard;
var                                                 
  CustomPage: TWizardPage;
  FileOneDesclabel: TLabel;
  FileTwoDesclabel: TLabel;
  FileThreeDesclabel: TLabel;

begin
  CustomPage := CreateCustomPage(wpWelcome, 'Multiple executable pre-launch wizard', '');
  FileOneButton := TNewRadioButton.Create(WizardForm);
  FileOneButton.Parent := CustomPage.Surface;
  FileOneButton.Top := 16;     
  FileOneButton.Width := CustomPage.SurfaceWidth;
  FileOneButton.Font.Style := [fsBold];
  FileOneButton.Font.Size := 9;
  FileOneButton.Caption := 'Run File #1'
  FileOneDescLabel := TLabel.Create(WizardForm);
  FileOneDescLabel.Parent := CustomPage.Surface;
  FileOneDescLabel.Left := 8;
  FileOneDescLabel.Top := FileOneButton.Top + FileOneButton.Height + 8;
  FileOneDescLabel.Width := CustomPage.SurfaceWidth;
  FileOneDescLabel.Height := 40;
  FileOneDescLabel.AutoSize := False;
  FileOneDescLabel.Wordwrap := True;
  FileOneDescLabel.Caption := FileOneDesc;

  FileTwoButton := TNewRadioButton.Create(WizardForm);
  FileTwoButton.Parent := CustomPage.Surface;
  FileTwoButton.Top := FileOneDesclabel.Top + FileOneDesclabel.Height + 8;
  FileTwoButton.Width := CustomPage.SurfaceWidth;
  FileTwoButton.Font.Style := [fsBold];
  FileTwoButton.Font.Size := 9;
  FileTwoButton.Caption := 'Run File #2'
  FileTwoDescLabel := TLabel.Create(WizardForm);
  FileTwoDescLabel.Parent := CustomPage.Surface;
  FileTwoDescLabel.Left := 8;
  FileTwoDescLabel.Top := FileTwoButton.Top + FileTwoButton.Height + 8;
  FileTwoDescLabel.Width := CustomPage.SurfaceWidth;
  FileTwoDescLabel.Height := 40;
  FileTwoDescLabel.AutoSize := False;
  FileTwoDescLabel.Wordwrap := True;
  FileTwoDescLabel.Caption := FileTwoDesc;

  FileThreeButton := TNewRadioButton.Create(WizardForm);
  FileThreeButton.Parent := CustomPage.Surface;
  FileThreeButton.Top := FileTwoDesclabel.Top + FileTwoDesclabel.Height + 10;
  FileThreeButton.Width := CustomPage.SurfaceWidth;
  FileThreeButton.Font.Style := [fsBold];
  FileThreeButton.Font.Size := 9;
  FileThreeButton.Caption := 'Run File #3'
  FileThreeDescLabel := TLabel.Create(WizardForm);
  FileThreeDescLabel.Parent := CustomPage.Surface;
  FileThreeDescLabel.Left := 8;
  FileThreeDescLabel.Top := FileThreeButton.Top + FileThreeButton.Height + 8;
  FileThreeDescLabel.Width := CustomPage.SurfaceWidth;
  FileThreeDescLabel.Height := 40;
  FileThreeDescLabel.AutoSize := False;
  FileThreeDescLabel.Wordwrap := True;
  FileThreeDescLabel.Caption := FileThreeDesc;
  end;
1

1 Answers

3
votes

The [Run] section has Check parameter like all the other sections whose entries are separated into parameters do. In your case I would write a common check function like this:

[Run]
Filename: {app}\file1.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}; Check: ShouldRunItem(1)
Filename: {app}\file2.exe; Flags: hidewizard runhidden 32bit; WorkingDir: {localappdata}; Check: ShouldRunItem(2)
Filename: {app}\file3.exe; Flags: hidewizard runhidden 64bit; WorkingDir: {localappdata}; Check: ShouldRunItem(3)
...

[Code]
function ShouldRunItem(Value: Integer): Boolean;
begin
  Result := False;
  case Value of
    1: Result := FileOneButton.Checked;
    2: Result := FileTwoButton.Checked;
    3: Result := FileThreeButton.Checked;
  end;
end;