So I basically have a .zip file in my {tmp}
directory, and want to extract it's contents in {tmp}
but only when my third form is done with it's work, not earlier. The reason is: Because in the third form I download this .zip from the internet and it is saved into {tmp}
. Now after this I want to extract these files into {tmp}
from which I am to get the files from the extracted folders, like the release notes, license agreement files to use in the rest of the forms in the installer. Meaning, already in the form after the third one, I am using the files extracted.
I can't find anywhere how to do this after a certain form. I only found in the run section how extracting is done.
EDIT: The old way I described proved not to work well on some Windows versions. It may pop up a dialog window instead of overwriting files silently. This is easy to google: CopyHere ignores options.
The new way:
- Mitchich Inno Download plugin
- 7zip
The new way uses 7zip standalone console version. It is a single 7za.exe
, you don't need the DLLs.
#include <idp.iss>
; Languages section
; Includes for Mitrich plugin's additional languages
; #include <idplang\Russian.iss>
[Files]
Source: "7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;
[Run]
Filename: {tmp}\7za.exe; Parameters: "x ""{tmp}\example.zip"" -o""{app}\"" * -r -aoa"; Flags: runhidden runascurrentuser;
[Code]
procedure InitializeWizard;
begin
idpAddFile('https://example.comt/example.zip', ExpandConstant('{tmp}\example.zip'));
{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
end;
If you want to download, unzip and use files (for example, as license agreement) before the installation starts, I can only give the general guideline:
- Enable welcome page in
[Setup]
: DisableWelcomePage=no
.
- Use
idpDownloadAfter(wpWelcome);
. Now it downloads right after "Welcome" page.
- You need an empty license file in
[Setup]
: LicenseFile=license.txt
for license page to show up. Or probably not empty, but with "Loading license agreement..." text.
- You implement
procedure CurPageChanged()
: if current page is wpLicense
then you call Exec()
function to launch 7zip and wait for it to terminate. No 7zip in [Run]
section now. Then you probably use LoadStringFromFile()
function to get license agreement from extracted file. Then put it into UI. Probably WizardForm.LicenseMemo.RTFText = ...
should work. Anyway, UI is accessible, if you have trouble setting the text, ask a separate question on this.
The old buggy way:
- Mitchich Inno Download plugin
- Inno Unzip Plugin
An equivalent, cleaner way without unzipper.dll
is described here. One way or another, it uses buggy CopyHere Windows feature.
#include <idp.iss>
; Languages section
; Includes for Mitrich plugin's additional languages
; #include <idplang\Russian.iss>
[Files]
Source: "unzipper.dll"; Flags: dontcopy
[Code]
procedure InitializeWizard;
begin
idpAddFile('https://example.comt/example.zip', ExpandConstant('{tmp}\example.zip'));
{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
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
{ Extract when "Finishing installation" setup step is being performed. }
{ Extraction crashes if the output dir does not exist. }
{ If so, create it first: }
{ CreateDir(ExpandConstant(...)); }
ExtractMe('{tmp}\example.zip', '{app}\');
end;
end;
You can probably try other things instead of wpReady
and ssPostInstall
. For my small zip this works well.