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:
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:
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.