Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup Prompt for external file location

Tags:

inno-setup

I currently use [Files] Flags: external to import user data into my installation, which is working.

I now need to prompt for a specific external file during the installation.

Use case:
We install software that requires a license file (not to be confused with the license agreement). I want to prompt the user for their license file. Once they provide a file, it would be copied to the DestDir.

I'm looking for a something like [Files] Flags: PromptForFile or a routine that achieves the same. Has someone already solved this?

like image 349
jrchilds Avatar asked Dec 05 '16 22:12

jrchilds


1 Answers

Use the CreateInputFilePage function to a create custom wizard page to prompt a user for the license file.

Then, use a scripted constant to use the selected path as a source path in the [Files] section.

[Files]
Source: "{code:GetLicensePath}"; DestDir: "{app}"; Flags: external

[Code]

var
  LicenseFilePage: TInputFileWizardPage;

procedure InitializeWizard();
begin
  LicenseFilePage :=
    CreateInputFilePage(
      wpSelectDir,
      'Select License File Location',
      'Where is your license file located?',
      'Select where License file is located, then click Next.');

  LicenseFilePage.Add(
    'Location of license file:',         
    'License files|*.lic|All files|*.*', 
    '.lic');                             
end;

function GetLicensePath(Param: string): string;
begin
  Result := LicenseFilePage.Values[0];
end;

License file page


TODO: You need to handle somehow a situation, when a user does not select any license file. Either don't allow to proceed (use the NextButtonClick) or skip the file installation (use the Check parameter).

like image 71
Martin Prikryl Avatar answered Oct 16 '22 00:10

Martin Prikryl