【问题标题】:Display license extracted from downloaded ZIP file in Inno Setup在 Inno Setup 中显示从下载的 ZIP 文件中提取的许可证
【发布时间】:2019-08-28 23:35:17
【问题描述】:

如何将在[Code] 部分下载然后在[Run] 部分解压缩的文件用作要安装的文件?

这是我的代码。问题是,我希望在下载完成后提取 zip 文件。我认为我的代码中没有这个。因为当我输入这个时,我得到一个错误:

[Setup]
LicenseFile={tmp}\apache-tomcat-9.0.0.M13\LICENSE
InfoBeforeFile={tmp}\apache-tomcat-9.0.0.M13\NOTICE
InfoAfterFile={tmp}\apache-tomcat-9.0.0.M13\RELEASE-NOTES

[Files]
Source: "{tmp}\apache-tomcat-9.0.0.M13\bin\tomcat9.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\...\apache-tomcat-9.0.0.M13\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

我收到编译错误,例如文件不存在。

如何使用我下载并提取的文件作为许可证和发行说明?

我不确定 .zip 文件是否在我想要提取的阶段被提取。这是我根据这些问题编译的代码:

#include <idp.iss>

[Setup]
LicenseFile=C:\..\Desktop\x64\apache-tomcat-9.0.0.M13\LICENSE
InfoBeforeFile=C:\...\x64\apache-tomcat-9.0.0.M13\NOTICE
InfoAfterFile=C:\...\x64\apache-tomcat-9.0.0.M13\RELEASE-NOTES
DisableWelcomePage=no

[Files]
Source: "C:\...\x64\apache-tomcat-9.0.0.M13\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "7za.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall;

[Code]

procedure InitializeWizard;
begin
  idpAddFile('http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.0.M13/bin/apache-tomcat-9.0.0.M13-windows-x64.zip', ExpandConstant('{tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip'));
  idpDownloadAfter(wpWelcome);
end;

[Run]
Filename: {tmp}\7za.exe; Parameters: "x {tmp}\apache-tomcat-9.0.0.M13-windows-x64.zip -o{app}\ * -r -aoa"; Flags: runhidden runascurrentuser;

【问题讨论】:

  • 您想将下载的 ZIP“安装”(=复制)到 {app} 吗?为什么?反正为什么不直接下载到{app},而不是{tmp}呢?
  • 今天晚些时候我会接受这个答案。
  • 而且这个问题还需要你解释一下。
  • 今天下午我会相应地更正我的其他帖子。我确实想安装下载的 zip。我很难做到这一点。我也无法格式化问题,所以它看起来像样,因为我在我的手机上。今天下午,我将把我们所有的松散话题都绑在我的帖子上。
  • 我在这里遇到的问题也是,解压缩似乎是在安装向导页面期间发生的,因为它在运行部分。我需要在下载完成后,在许可协议之前解压缩它,因为我要从下载的 zip 中获取许可协议。

标签: inno-setup


【解决方案1】:
  • 通过设置假许可证文件来启用“许可证”页面。
  • 在欢迎页面之后下载带有许可证的 ZIP 文件(您必须明确启用它)。
  • 在下载页面的“下一步”按钮处理程序中,解压缩 ZIP 文件,然后加载许可证(您必须对此进行编码,不能使用 [Run] 部分)。

代码使用来自How to get Inno Setup to unzip a file it installed (all as part of the one installation process)UnZip 函数,该函数使用Shell.Application。如果您更喜欢外部解压缩应用程序,可以使用Exec 函数在调用UnZip 的同一位置执行它。

#include "idp.iss"

[Setup]
DisableWelcomePage=no
LicenseFile=fake.txt

const
  TomcatVersion = '9.0.0.M13';

var
  TomcatZipPath: string;

procedure InitializeWizard();
var
  TomcatZipUrl: string;
  TomcatZipFile: string;
begin
  TomcatZipFile := 'apache-tomcat-' + TomcatVersion + '-windows-x64.zip';
  TomcatZipPath := ExpandConstant('{tmp}\' + TomcatZipFile);
  TomcatZipUrl :=
    'http://www-us.apache.org/dist/tomcat/tomcat-9/v' + TomcatVersion +
    '/bin/' + TomcatZipFile;
  idpAddFile(TomcatZipUrl, TomcatZipPath);
  idpDownloadAfter(wpWelcome);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = IDPForm.Page.ID then
  begin
    idpShowDetails(False);
    IDPForm.DetailsButton.Visible := False;

    WizardForm.NextButton.Enabled := False;
    WizardForm.BackButton.Visible := False;
    WizardForm.CancelButton.Enabled := False;
    try
      IDPForm.TotalProgressLabel.Caption := 'Extracting files...';
      UnZip(TomcatZipPath, ExpandConstant('{tmp}'));
    finally
      WizardForm.BackButton.Visible := True;
      WizardForm.NextButton.Enabled := True;
      WizardForm.CancelButton.Enabled := True;
    end;

    WizardForm.LicenseMemo.Lines.LoadFromFile(
      ExpandConstant('{tmp}\apache-tomcat-9.0.0.M13\LICENSE'));
  end;

  Result := True;
end;

【讨论】:

  • 我同意,但是我如何将它与那个 java 安装集成在一起,它也在下一个按钮事件中
  • 我需要安装java然后得到这个屏幕。我试着把 thwm 放在一起,它编译但是当按下第一个下一步按钮时我得到一个错误
  • 这是一个新问题。问它。并向我们​​展示您的新代码。
  • 不过,您可能只是想将if CurPageID = DownloadPage.ID thenstackoverflow.com/a/40683075/850848 更改为if CurPageID = wpLicense then,不是吗?
  • 试过了,有问题。稍后我会试试这个。非常感谢您对 inno 设置的帮助。我很快就要结束了。
猜你喜欢
  • 2016-03-04
  • 2022-06-13
  • 1970-01-01
  • 2014-11-23
  • 1970-01-01
  • 2022-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多