Inno Setup(如何动态获取文件路径)? [英] Inno Setup (How to get dynamically path to file)?

查看:937
本文介绍了Inno Setup(如何动态获取文件路径)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Inno中制作安装脚本,我想知道如何获得非硬编码"路径.这是示例:

I'm making a setup script in Inno and I was wondering, how can I get non "hardcoded" path. Here is example:

提前谢谢!

解决方案:

您可以通过使用预定义变量

You can get .iss folder by using predefined variable

SourcePath

SourcePath

用法类似于:{#SourcePath} \ ??? \ bin \ x86 \ Release \ ???.exe

Usage would be like: {#SourcePath}\???\bin\x86\Release\???.exe

感谢所有贡献者!

推荐答案

关于

The reference about the source directory says (emphasized by me):

默认情况下,安装编译器希望找到脚本的[Files]部分Source参数中引用的文件,以及所引用的文件 在[设置]部分的下,脚本文件位于同一目录下 如果它们不包含标准路径名,则位于.指定 在不同的源目录中,在 脚本的[设置]部分.

By default, the Setup Compiler expects to find files referenced in the script's [Files] section Source parameters, and files referenced in the [Setup] section, under the same directory the script file is located if they do not contain fully qualified pathnames. To specify a different source directory, create a SourceDir directive in the script's [Setup] section.

这还包括用于指定文件的相对路径的选项.因此,假设您具有以下文件结构,并且未在

This includes also option to specify relative path to the files. So let's assume that you have the following file structure and you didn't specify a different path in the SourceDir directive:

C:\Deploy\Script.iss
C:\Deploy\MyProg.exe
C:\Deploy\SubFolder\MyOtherProg.exe
C:\Folder\SomeFile.txt

现在,如果要将MyProg.exe包含在通过Script.iss脚本编译的设置中,则可以仅指定不带路径的文件名,因为MyProg.exe文件存储在与该文件夹相同的文件夹中脚本,因此您只需编写:

Now if you'd like to include the MyProg.exe into the setup compiled from the Script.iss script, you could specify just the file name without the path, since the MyProg.exe file is stored in the same folder as the script, so you could write just:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

您可以使用MyOtherProg.exe的相对路径,该路径存储在Script.iss脚本存储文件夹的子文件夹中,如下所示:

And you can use a relative path to the MyOtherProg.exe which is stored in the subfolder of the folder where the Script.iss script is stored this way:

[Files]
Source: "SubFolder\MyOtherProg.exe"; DestDir: "{app}"

您还可以使用相对路径包括存储在存储脚本的父文件夹的子文件夹中的SomeFile.txt:

As well as you can use a relative path to include the SomeFile.txt stored in a subfolder of the parent folder where the script is stored:

[Files]
Source: "..\Folder\SomeFile.txt"; DestDir: "{app}"

有关相对路径约定的更多信息,您可以在

More about relative path conventions you can read in this chapter.

这篇关于Inno Setup(如何动态获取文件路径)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆