Search code examples
inno-setuppascalscript

Inno Setup unzip file from input user


I try to unzip in installation file which I download from my repository. I found this code:
How to get Inno Setup to unzip a file it installed (all as part of the one installation process)

But I need to input from user in custom page about version of application in the repository, download it and try unzip. How send to value from input to ExtractMe('{tmp}\INPUT FROM USER VERSION.zip', '{app}\');

begin
  {Page for input Version}
  UserPage := CreateInputQueryPage(wpWelcome,
    'Number of Version', 'example : 1.8.20',
    'Program will download your input');
  UserPage.Add('Version:', False);
  UserPage.Values[0] := GetPreviousData('Version', '1.8.20');
end;

{Called when the user clicks the Next button}
function NextButtonClick(CurPageID: Integer): Boolean;
var
  Version: string;
  FileURL: string;
begin
  if CurPageID = wpReady then
  begin
    Version := UserPage.Values[0];
    {Download}

    FileURL := Format('http://127.0.0.1/repository/ia/ats-apps/ia-client.zip/%s/ia-client.zip-%0:s.zip', [Version]); <-- FROM HERE TO BELOW
    idpAddFile(FileURL, ExpandConstant(Format('{tmp}\%s.zip', [Version])));
    idpDownloadAfter(wpReady);
  end;
  Result := True;
end;

procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';

procedure ExtractMe(src, target : AnsiString);
begin
  unzip(ExpandConstant(src), ExpandConstant(target));
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then 
  begin
    ExtractMe('{tmp}\INPUT FROM USER VERSION.zip', '{app}\'); <--HERE
  end;
end;

Thanks for tip.


Solution

  • The same way as you are already using in the NextButtonClick: Read the UserPage.Values[0].

    ExtractMe(Format('{tmp}\%s.zip', [UserPage.Values[0]]), '{app}\');