Codename K
Codename K

Reputation: 744

Refer to a subfolder of an installation path without repeating the name throughout the script

When you give the folder location in the Inno Setup installer it sets it to the constant {app}. If the folder location is given as C:\Program Files\Test1, this will set it to {app} variable. When the user gives this path, is it possible to add to the {app} variable like this C:\Program Files\Test1\MyApp-3.1?

If the user gives the folder location as C:\Program Files\Test1 and clicks the Next button then it should change it to C:\Program Files\Test1\MyApp-3.1. Is this possible?

According to this page {app} is a directory constant.

I have set many files to run in the following sections,

[Icons]
[Run]
[InstallDelete]
[UninstallRun]

For example, {app}\Run.exe. Instead of changing the {app}\Run.exe to {app}\Program\Run.exe, I need to change the {app} to C:\Program Files\Test1\MyApp-3.1.

I have a program which always needs to run from the folder structure MyApp-3.1\Run.exe. If the user select the installation folder as C:\Program Files\Test1 then the folder needs to be set as C:\Program Files\Test1\MyApp-3.1. The easy way is to create the folder MyApp-3.1 with the Run.exe in it and add that folder to the installer. So it will install the MyApp-3.1 folder. The issue is if the folder name is change to MyApp-3.2 then there have to be lot changes in the code.

The question is can you set the {app} variable after clicking the Next button in folder selection dialog?

Upvotes: 2

Views: 308

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202282

It looks like you actually need a preprocessor macro:

#define DestPath "{app}\MyApp-3.1"

[Files]
Source: "Run.exe"; DestDir: "{#DestPath}"
Source: "Otherfile"; DestDir: "{#DestPath}"

[Icons]
Name: "{commondesktop}\My Program"; Filename: "{#DestPath}\Run.exe"; \
    WorkingDir: "{#DestPath}"

[Run]
Filename: "{#DestPath}\Run.exe"; Parameters: "/install"

[UninstallRun]
Filename: "{#DestPath}\Run.exe"; Parameters: "/uninstall"

If you need to change the subfolder name, just change the DestPath definition:

#define DestPath "{app}\MyApp-3.2"

Upvotes: 2

Related Questions