inno-setup

Avoid displaying filenames of Inno Setup sub-installers


I am trying to use the idea from Inno Setup - How to hide certain filenames while installing? (FilenameLabel)

The only sure solution is to avoid installing the files, you do not want to show, using the [Files] section. Install them using a code instead. Use the ExtractTemporaryFile and CopyFile functions

But the files that I want to hide are using in the [Run] Section:

[Files]
Source: "_Redist\DXWebSetup.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Run]
Filename: "{tmp}\DXWebSetup.exe"; Components: DirectX; StatusMsg: "Installing DirectX..."; \
  BeforeInstall: StartWaitingForDirectXWindow; AfterInstall: StopWaitingForDirectXWindow

How to hide (while installing, in filenamelabel) using [Files] section, ExtractTemporaryFile and CopyFile functions?


Solution

  • The easiest is to give up on the standard [Files] and [Run] sections and code everything on your own in the CurStepChanged event fuction:

    [Files]
    Source: "dxwebsetup.exe"; Flags: dontcopy
    
    [Code]
    
    procedure CurStepChanged(CurStep: TSetupStep);
    var
      ProgressPage: TOutputProgressWizardPage;
      ResultCode: Integer;
    begin
      if CurStep = ssInstall then { or maybe ssPostInstall }
      begin
        if IsComponentSelected('DirectX') then
        begin
          ProgressPage := CreateOutputProgressPage('Installing prerequsities', '');
          ProgressPage.SetText('Installing DirectX...', '');
          ProgressPage.Show;
          try
            ExtractTemporaryFile('dxwebsetup.exe');
            StartWaitingForDirectXWindow;
            Exec(ExpandConstant('{tmp}\dxwebsetup.exe'), '', '', SW_SHOW,
                 ewWaitUntilTerminated, ResultCode);
          finally
            StopWaitingForDirectXWindow;
            ProgressPage.Hide;
          end;
        end;
      end;
    end;
    

    This even gives you a chance to check for results of the sub-installer. And you can e.g. prevent the installation from continuing, when the sub-installer fails or is cancelled.

    Then it's easier to use the PrepareToInstall instead of the CurStepChanged.


    Another option is to display a custom label, while extracting the sub-installer.
    See Inno Setup - How to create a personalized FilenameLabel with the names I want?