0

I'm using Inno Setup 6.1.2. I've made an installer that downloads zip and 7z files off the internet,and it should then after installing them, uncompress them to {app} directory,and at the end delete zip and 7z files,while keeping extracted content intact.

The problem is,instead of that,it doesn't uncompress files,it just downloads them to {app} directory.I've tried using deleteafterinstall flag,but it just deletes zip and 7z files,resulting in downloading only non-external files.

I want the installer to delete zip and 7z files after uncompressing them to specific directory.How can i do that?

Here's the code:

[Setup]
DefaultDirName=C:\Program Files (x86)\example
DisableDirPage=no
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
PrivilegesRequired=admin
PrivilegesRequiredOverridesAllowed=commandline
OutputDir=C:\example1\Output
OutputBaseFilename=test

SolidCompression=yes
Compression=lzma
WizardStyle=modern

[Files]
Source: "{src}\example2.7z"; DestDir: "{app}"; Flags: external

Source: "C:\a\b.ini"; DestDir: "{app}\example2\something1"; Flags: ignoreversion recursesubdirs

Source: "{src}\example3.7z"; DestDir: "{app}\example2\something1"; Flags: external

[Code]
var
  DownloadPage: TDownloadWizardPage;

function OnDownloadProgress(const Url, FileName: String; const Progress, ProgressMax: Int64): Boolean;
begin
  if Progress = ProgressMax then
    Log(Format('Successfully downloaded files to {app}: %s', [FileName]));
  Result := True;
end;

procedure InitializeWizard;
begin
  DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = wpReady then begin
    DownloadPage.Clear;
    DownloadPage.Add('https://example.com/example2.7z', 'example2.7z', '');

    DownloadPage.Add('https://example.com/example3', 'example3.7z', '');
    DownloadPage.Show;
    try
      try
        DownloadPage.Download; // This downloads the files to {app}
        Result := True;
      except
          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
        Result := False;
      end;
    finally
      DownloadPage.Hide;
    end;
  end else
    Result := True;
end;
Someone
  • 9
  • 3
  • I see no where bin your script where you actually attempt to decompress your downloaded ZIP files. Shouldn't you have a `[InstallRun]` section (might be another section) and add entries there to unpack the ZIP files and then delete them? There has to be examples on the internet about how to unzip an archive using Inno Setup. – Andrew Truckle Jul 06 '21 at 04:18
  • I thought that Inno Setup was compressing files on it's own. How do i add selected components as entires,though? – Someone Jul 06 '21 at 08:20
  • Inno Setup compresses the data files into a archive (the setup file). But that is all. If you decided to download a ZIP file at install time then you need to take care of what to do with that file. A quick search on the internet showed an example of how to unpack ZIP files: https://stackoverflow.com/a/6225118/2287576 – Andrew Truckle Jul 06 '21 at 08:48
  • Is it possible to just extract files from the internet without downloading them? – Someone Jul 06 '21 at 09:12
  • I don't have enough knowledge for that but I doubt it. But you are now steering your question in a different direction. – Andrew Truckle Jul 06 '21 at 09:34
  • I only asked that to see if i could simplify the instalation. – Someone Jul 06 '21 at 09:53
  • In a number of places the question says "compress" - did you mean UNcompress? – StayOnTarget Jul 06 '21 at 13:14
  • Yes,i meant uncompress/unpack zip and 7z files. – Someone Jul 06 '21 at 14:07
  • Why do you need to install archive files and then decompress them? Why not just include the (uncompressed) files as part of the installer and let Inno Setup install and decompress automatically? – Bill_Stewart Jul 06 '21 at 15:44
  • "Why do you need to install archive files and then decompress them?" Because they are downloaded from internet,and they need to be updated. – Someone Jul 06 '21 at 16:22
  • Why do they need to be downloaded? Why not put the most up-to-date files in the installer? – Bill_Stewart Jul 06 '21 at 20:03
  • Because that way i won't have to constantly change files in installer. – Someone Jul 06 '21 at 22:08
  • I don't recommend this as a core part of your installer (require internet access) because then your installer won't work in an offline scenario. – Bill_Stewart Jul 07 '21 at 22:18
  • Good point. I will add offline installation but i also would like if online one functioned properly. – Someone Jul 08 '21 at 08:09

0 Answers0