1

I have a requirement to install a setup (created via inno setup) in two different destination folders.

My goal is to use a ini file to determine the destination directory while installing it.

Setup.ini file

[Settings]
#======================================================================
DestDir=C:\\Software\\Path1
#======================================================================

Inno Setup File

#define DestinationDir ReadIni("Setup.ini", "Settings", "DestDir", "")

[Files]
Source: "D:\Publish\MyService.exe";                 DestDir: "{#DestDir}";    Flags: ignoreversion

[Run]
Filename: "{#DestDir}\MyService.exe";        Parameters: "-i -name MyService-display ""My Service""";       StatusMsg: "Installing my service";

I copy the installer file (setup.exe) to the server together with the .ini file (set to path1) and run the installer. I expect myService.exe file to be copied into Path1 ("C:\Software\Path1").

enter image description here

Then I will change the .ini file to following and re-run the installer. I expect myService.exe file to be copied into Path2 ("C:\Software\Path2").

[Settings]
#======================================================================
DestDir=C:\\Software\\Path2
#======================================================================

However, this is not working at all. Seems like the ini file can be referred only when we creating the setup installer via inno setup, not while executing the installer. Any suggestions how to achieve this?

Dumi
  • 1,414
  • 4
  • 21
  • 41

1 Answers1

0

Your code is using a preprocessor. The preprocessor evaluates on compile-time. It has no effect on run/install-time.


Inno Setup has a built-in functionality to specify the target path. You can use a command-line switch /DIR= to specify the path:

setup.exe /DIR=C:\Software\Path1

Another option is using special INI file like below using /LOADINF switch:

[Setup]
Dir=C:\Software\Path1

A related question: Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992