Downloading file with Inno Setup only when user chooses to

后端 未结 2 1483
时光取名叫无心
时光取名叫无心 2021-01-14 03:32

Question: I’d like to know how to script to download a second file which is a zip but initially give a choice between two zip files; download, unzip and delete the zip. The

相关标签:
2条回答
  • 2021-01-14 04:02

    Only after posting my answer, I've noticed that despite you tagging the question inno-download-plugin, you are actually using InnoTools Downloader. Do not – InnoTools Downloader is dead and unmaintained.

    Also note that the upcoming Inno Setup 6.1 will have a built-in support for downloads. With that API, the solution will be easier, but different than what is shown below to IDP.


    In the examples folder of Inno Download Plugin installation, there are components1.iss and components2.iss examples.

    The first shows how to use idpAddFileComp to conditionally download a file, when a component is selected.

    I'm re-posting a full example:

    ; Uncomment one of following lines, if you haven't checked "Add IDP include path to ISPPBuiltins.iss" option during IDP installation:
    ;#pragma include __INCLUDE__ + ";" + ReadReg(HKLM, "Software\Mitrich Software\Inno Download Plugin", "InstallDir")
    ;#pragma include __INCLUDE__ + ";" + "c:\lib\InnoDownloadPlugin"
    
    [Setup]
    AppName          = My Program
    AppVersion       = 1.0
    DefaultDirName   = {pf}\My Program
    DefaultGroupName = My Program
    OutputDir        = userdocs:Inno Setup Examples Output
    
    #include <idp.iss>
    
    [Types]
    Name: full;    Description: "Full installation"
    Name: compact; Description: "Compact installation"
    Name: custom;  Description: "Custom installation"; Flags: iscustom
    
    [Components]
    Name: app;  Description: "My Program";  Types: full compact custom; Flags: fixed
    Name: help; Description: "Help files";  Types: full
    Name: src;  Description: "Source code"; Types: full
    
    [Files]
    Source: "{tmp}\app.exe";  DestDir: "{app}"; Flags: external; ExternalSize: 1048576; Components: app
    Source: "{tmp}\help.chm"; DestDir: "{app}"; Flags: external; ExternalSize: 1048576; Components: help
    Source: "{tmp}\src.zip";  DestDir: "{app}"; Flags: external; ExternalSize: 1048576; Components: src
    
    [Icons]
    Name: "{group}\My Program"; Filename: "app.exe";  Components: app
    Name: "{group}\Help file";  Filename: "help.chm"; Components: help
    Name: "{group}\{cm:UninstallProgram,My Program}"; Filename: "{uninstallexe}"
    
    [Code]
    procedure InitializeWizard;
    begin
        idpAddFileComp('http://127.0.0.1/app.exe',  ExpandConstant('{tmp}\app.exe'),  'app');
        idpAddFileComp('http://127.0.0.1/help.chm', ExpandConstant('{tmp}\help.chm'), 'help');
        idpAddFileComp('http://127.0.0.1/src.zip',  ExpandConstant('{tmp}\src.zip'),  'src');
    
        idpDownloadAfter(wpReady);
    end;
    

    Caveat: The component name passed to idpAddFileComp must be in lowercase (the actual component name can use uppercase).

    0 讨论(0)
  • 2021-01-14 04:08

    Inno Setup 6.1.2 has new DownloadTemporaryFile support function to download files without using a third-party tool:

    • Supports HTTPS (but not expired or self-signed certificates) and HTTP.
    • Redirects are automatically followed and proxy settings are automatically used.
    • Safe to use from services unlike existing third-party tools.
    • Supports SHA-256 hash checking of the downloaded file.
    • Supports basic authentication.

    I added this answer because even the IDP plugin referred in the accepted answer was last updated in 2016 and did not work for me now and I had to change to the new function provided by Inno Setup 6.1.2.

    0 讨论(0)
提交回复
热议问题