1

How do use files that are downloaded in the [Code] section then unzipped in the [Run] section, as files to be installed?

Here is my code. The thing is, I want the zip files extracted after my downloads are finished. I don't think I have that here in my code. Because when I type this I get an error:

Under 

[Setup]
LicenseFile={tmp}\apache-tomcat-9.0.0.M13\LICENSE
InfoBeforeFile={tmp}\apache-tomcat-9.0.0.M13\NOTICE
InfoAfterFile={tmp}\apache-tomcat-9.0.0.M13\RELEASE-NOTES

Under

[Files]
Source: "{tmp}\apache-tomcat-9.0.0.M13\bin\tomcat9.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\...\apache-tomcat-9.0.0.M13\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

I get compilation errors like that the file doesn't exist.

How do I use the files I downloaded and extracted as license and release notes?

I am not sure that the the .zip file is even extracted at the stage I wanted to be extracted. Here is my code that compiles based on these questions:

#include <idp.iss>

[Setup]
LicenseFile=C:\..\Desktop\x64\apache-tomcat-9.0.0.M13\LICENSE
InfoBeforeFile=C:\...\x64\apache-tomcat-9.0.0.M13\NOTICE
InfoAfterFile=C:\...\x64\apache-tomcat-9.0.0.M13\RELEASE-NOTES
DisableWelcomePage=no

[Files]
Source: "C:\...\x64\apache-tomcat-9.0.0.M13\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;

[Code]

procedure InitializeWizard;
begin
  idpAddFile('http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M13/bin/apache-tomcat-9.0.0.M13-windows-x64.zip', ExpandConstant('{tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip'));
  idpDownloadAfter(wpWelcome);
end;

[Run]
Filename: {tmp}\7za.exe; Parameters: "x {tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip -o{app}\ * -r -aoa"; Flags: runhidden runascurrentuser;
Community
  • 1
  • 1
  • Do you want to "install" (=copy) the downloaded ZIP to the {app}? Why? Anyway, why don't you download it directly to `{app}`, instead of `{tmp}`? – Martin Prikryl Nov 21 '16 at 11:13
  • I will accept that answer later today. –  Nov 21 '16 at 11:57
  • And you still need to explain this question. – Martin Prikryl Nov 21 '16 at 12:14
  • I will correct my other posts accordingly this afternoon. I do want to install the downloaded zip. I have trouble doing this. Also i cannot format the question so it looks presentable because i am on my phone. This afternoon i will tie us all loose ends on my posts. –  Nov 21 '16 at 12:17
  • The problem that i have here also is that the unzipping seems to happen during the installing wizard page, because it is in the run section. I need it to unzip right after the downloads are finished, before the license agreement, because i am to get the license agreement from the downloaded zip. –  Nov 21 '16 at 12:20
  • But you know how to trigger an action just after the download finishes. You execute the installer this way already according [to this answer that you never accepted](http://stackoverflow.com/q/40679399/850848). All you need to do is to call the `ExtractMe` function from [this answer that you never accepted](http://stackoverflow.com/a/40705360/850848) the same way (The answer is actually good, despite the poster labeling it "buggy". It just pops up progress window on Windows XP, but that's a minor issue). – Martin Prikryl Nov 21 '16 at 12:34
  • If you cannot format a question on phone, do not post questions from phone. That's a lame excuse! – Martin Prikryl Nov 21 '16 at 12:36
  • The reasons why i cannot post from my computer in the mornings are very complicated. I thank you for your input very much. –  Nov 21 '16 at 12:37

1 Answers1

1
  • Enable the "license" page, by setting a fake license file.
  • Download the ZIP file with the license just after a welcome page (you have to explicitly enable it).
  • In the "next" button handler of the download page, extract the ZIP file, and load the license (you have to code this, you cannot use the [Run] section).

The code uses an UnZip function from How to get Inno Setup to unzip a file it installed (all as part of the one installation process) that uses the Shell.Application. If you prefer an external unzip application, you can execute it using Exec function, on the same place the UnZip is called.

#include "idp.iss"

[Setup]
DisableWelcomePage=no
LicenseFile=fake.txt

const
  TomcatVersion = '9.0.0.M13';

var
  TomcatZipPath: string;

procedure InitializeWizard();
var
  TomcatZipUrl: string;
  TomcatZipFile: string;
begin
  TomcatZipFile := 'apache-tomcat-' + TomcatVersion + '-windows-x64.zip';
  TomcatZipPath := ExpandConstant('{tmp}\' + TomcatZipFile);
  TomcatZipUrl :=
    'http://www-us.apache.org/dist/tomcat/tomcat-9/v' + TomcatVersion +
    '/bin/' + TomcatZipFile;
  idpAddFile(TomcatZipUrl, TomcatZipPath);
  idpDownloadAfter(wpWelcome);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = IDPForm.Page.ID then
  begin
    idpShowDetails(False);
    IDPForm.DetailsButton.Visible := False;

    WizardForm.NextButton.Enabled := False;
    WizardForm.BackButton.Visible := False;
    WizardForm.CancelButton.Enabled := False;
    try
      IDPForm.TotalProgressLabel.Caption := 'Extracting files...';
      UnZip(TomcatZipPath, ExpandConstant('{tmp}'));
    finally
      WizardForm.BackButton.Visible := True;
      WizardForm.NextButton.Enabled := True;
      WizardForm.CancelButton.Enabled := True;
    end;

    WizardForm.LicenseMemo.Lines.LoadFromFile(
      ExpandConstant('{tmp}\apache-tomcat-9.0.0.M13\LICENSE'));
  end;

  Result := True;
end;

Downloading

Extracting

License

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • I agree, but how do i integrate this with that java installation, which is also inside next button event –  Nov 21 '16 at 14:41
  • I need that java installation to go through then get this screen. I tried puttting thwm together, it compiled but when pressing the first next button i got an error –  Nov 21 '16 at 14:42
  • That's a new question. Ask it. And show us your new code. – Martin Prikryl Nov 21 '16 at 14:48
  • Though, you just probably want to change the `if CurPageID = DownloadPage.ID then` from http://stackoverflow.com/a/40683075/850848 to `if CurPageID = wpLicense then`, don't you? – Martin Prikryl Nov 21 '16 at 14:49
  • Tried that, got problems. Ill try this out later. Thabk you so much for your help with inno setup. I am comming to an end soon. –  Nov 21 '16 at 14:51