使用 Inno Setup 从子目录(相对路径)安装外部文件

Install external file from subdirectory (relative path) using Inno Setup

我想安装一个外部文件。

我的安装程序位于

c:\somedir\setup.exe

外部文件位于

c:\somedir\download\MyApp.exe

我的代码是

[Files]
Source:"\download\MyApp.exe"; DestDir: "{app}";Flags: external skipifsourcedoesntexist

出于某种原因,Inno Setup 似乎找不到此文件。

谁能告诉我我做错了什么?

谢谢。

使用 {src} 常量:

[Files]
Source:"{src}\download\MyApp.exe"; DestDir: "{app}";Flags: external skipifsourcedoesntexist

你有两个问题:

  • 相对于 c:\somedir\ 的路径 \download\MyApp.exe 解析为 c:\download\MyApp.exe,因为前导 \ 返回到根文件夹。您需要使用 download\MyApp.exe.

  • 无论如何,Inno Setup 不会解析相对于安装程序的外部文件路径。您必须使用完整路径,请参阅 Source parameter:

    的文档

    When the flag external is specified, Source must be the full pathname of an existing file (or wildcard) on the distribution media or the user's system (e.g. "{src}\license.ini").

    您可以使用 {src} constant 获取安装程序文件夹的完整路径。


[Files]
Source: "{src}\download\MyApp.exe"; DestDir: "{app}"; \
    Flags: external skipifsourcedoesntexist