I am using Inno Setup to distribute my application. Is it possible to check in Inno Script for a particular condition and download and install some file from internet if required.
Asked
Active
Viewed 2.1k times
4 Answers
16
Inno Download Plugin by Mitrich Software.
- It's an InnoSetup script and DLL, which allows you to download files as part of your installation.
- It supports FTP, HTTP and HTTPS.
- It's kind of a drop-in replacement for InnoTools Downloader. Only few changes required.
- It brings a decent download display and HTTPS and Mirror(s) support.
Example:
#include <idp.iss>
[Files]
Source: "{tmp}\file.zip"; DestDir: "{app}"; Flags: external; ExternalSize: 1048576
[Code]
procedure InitializeWizard();
begin
idpAddFileSize('http://127.0.0.1/file.zip', ExpandConstant('{tmp}\file.zip'), 1048576);
idpDownloadAfter(wpReady);
end.
Jens A. Koch
- 37,346
- 13
- 106
- 132
-
4I would prefer Inno Download Plugin mentioned here before InnoTools Downloader. – TLama Jul 01 '15 at 09:21
12
Inno Setup 6.1 and newer has a built-in support for downloads. No 3rd party solution are needed anymore.
Check the Examples\CodeDownloadFiles.iss in Inno Setup installation folder.
The important parts of the example are:
[Files]
; These files will be downloaded
Source: "{tmp}\innosetup-latest.exe"; DestDir: "{app}"; Flags: external
Source: "{tmp}\ISCrypt.dll"; DestDir: "{app}"; 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 file to {tmp}: %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://jrsoftware.org/download.php/is.exe', 'innosetup-latest.exe', '');
DownloadPage.Add('https://jrsoftware.org/download.php/iscrypt.dll', 'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
DownloadPage.Show;
try
try
DownloadPage.Download;
Result := True;
except
SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
Result := False;
end;
finally
DownloadPage.Hide;
end;
end else
Result := True;
end;
For alternatives, see Running a program after it is downloaded in Code section in Inno Setup
Martin Prikryl
- 167,268
- 50
- 405
- 846
11
Yes, there is a library called InnoTools Downloader which has samples that do pretty much this. They can be conditioned on anything you want using normal Inno code.
Deanna
- 23,400
- 7
- 68
- 152
-
1InnoTools Downloader is dead (not maintained + does not support Unicode Inno Setup + does not support HTTPS + etc). Use Inno Download Plugin instead, as shown in the answer by @Jens. – Martin Prikryl May 28 '19 at 05:32
-
3And now, Inno Setup 6.1 supports downloads natively. So no 3rd party solution is needed. See [my answer](https://stackoverflow.com/q/6887428/850848#66100456). – Martin Prikryl Feb 08 '21 at 12:16
1
Found on Inno 3rd Party is one very similar in scope and style to the Inno Download Plugin, DWinsHs.
Included with an easy and intuitive chm file which requires unblocking to view.
Laurie Stearn
- 895
- 1
- 12
- 32
-
4Please note: link only answers are discouraged - they turn useless when the links break. And links tend to break. Often. – GhostCat Jun 22 '17 at 07:32