安装时解压文件

Extract file during installation

我正在尝试在 [Codes] 部分使用 7zip 提取文件,因为我想在 [Files] 部分复制任何文件之前提取文件。

下面的代码我不明白,我尝试并更改了它,但看起来 The system cannot find the specified file

我是不是做错了什么?

[Files]

// Copy 7za.exe to {tmp} folder
Source: "toolszipza.exe"; DestDir: "{tmp}zip"; Flags: deleteafterinstall;

Source: "{tmp}\launchers\Launcher1"; DestDir: "{app}"; Flags: onlyifdoesntexist external; BeforeInstall: ExtractLauncher
Source: "{tmp}\launchers\Launcher2"; DestDir: "{app}"; Flags: onlyifdoesntexist external; BeforeInstall: ExtractLauncher

// --------------------------- Extract Launcher --------------------------- \

[Code]
var
 ResultCode: integer;

procedure ExtractLauncher();
begin                                                                               
  Exec(ExpandConstant('{tmp}zipza.exe'), 'x "{tmp}\launchers\launcher.zip" -o"{tmp}\launchers" * -r -aoa', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) 
  MsgBox(SysErrorMessage(ResultCode), mbError, MB_OK);
end;

launcher.zip 文件在安装过程中下载到 {tmp}\launchers 文件夹

我一直在查看 {tmp} 文件夹,launcher.zip 文件和 7za.exe 是在 运行 我的 [Codes] 之前创建的,我这样做了以确保他们在 运行 代码时就在那里。 是的,他们在 运行 编写代码之前就已经存在了。

感谢 Martin's Prikryl 评论,我刚刚将 ExpandConstant 添加到命令行的其余部分并且代码有效!

原来是这样的:

[Files]

// Copy 7za.exe to {tmp} folder
Source: "toolszipza.exe"; DestDir: "{tmp}zip"; Flags: deleteafterinstall;

Source: "{tmp}\launchers\Launcher1"; DestDir: "{app}"; Flags: onlyifdoesntexist external; BeforeInstall: ExtractLauncher
Source: "{tmp}\launchers\Launcher2"; DestDir: "{app}"; Flags: onlyifdoesntexist external; BeforeInstall: ExtractLauncher

// --------------------------- Extract Launcher ---------------------------

[Code]
var
 ResultCode: integer;

procedure ExtractLauncher();
begin                                                                               
  Exec(ExpandConstant('{tmp}zipza.exe'), ' x ' + ExpandConstant('{tmp}\launchers\launcher.zip') + ' -o' + ExpandConstant('{tmp}\launchers') + ' * -r -aoa', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) 
  MsgBox(SysErrorMessage(ResultCode), mbError, MB_OK);
end;