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

心不动则不痛 提交于 2020-05-13 11:44:45

问题


I would like to install an external file.

My installer is located in

c:\somedir\setup.exe

And the external file is located in

c:\somedir\download\MyApp.exe

My code to do that is

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

For some reason, Inno Setup does not seem to find this file.

Can anybody tell me what I'm doing wrong?

Thank you.


回答1:


You have two problems:

  • The path \download\MyApp.exe relative to c:\somedir\ resolves to c:\download\MyApp.exe, as the leading \ goes back to the root folder. You would need to use download\MyApp.exe.

  • The Inno Setup does not resolve external file paths relatively to the installer anyway. You have to use a full path, see the documentation for the 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").

    You can use the {src} constant to get a full path to the installer folder.


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



回答2:


Use the {src} constant:

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


来源:https://stackoverflow.com/questions/37408121/install-external-file-from-subdirectory-relative-path-using-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!