How to install same file to multiple locations (Inno Setup)

2.3k views Asked by At

I am trying to figure out how to copy files to multiple locations with Inno Setup installer.

[Files]
Source: "myfolder\*" DestDir: {multipe dirs?}

Basically I have a function GetInstallDirs() that looks for all the keys in a registry location and form an array for with the plugin install path and returns an array of directories. Instead of adding a line for each directory, is there a way DestDir takes multiple directories?

1

There are 1 answers

0
Martin Prikryl On

So you wanted to use DestDir: "{code:GetInstallDirs}"?

The DestDir can point to a single folder only.

You have to create more entries in [Files] section, if you need to install the same file to multiple folders. Note that Inno Setup will compile the source file only once to the installer.

I'm not aware of an easy way to create the multiple entries programmatically.

You could create "a lot" of entries likes:

[Files]
Source: "myfolder*"; DestDir: "{code:GetInstallDirs|1}"; Check HasInstallDir(1)
Source: "myfolder*"; DestDir: "{code:GetInstallDirs|2}"; Check HasInstallDir(2)
Source: "myfolder*"; DestDir: "{code:GetInstallDirs|3}"; Check HasInstallDir(3)
...

You can create a large list of such entries using Inno Setup preprocessor.

#define EntryI

#sub AddEntry

Source: "myfolder*"; DestDir: "{code:GetInstallDirs|{#EntryI}}"; \
    Check: HasInstallDir({#EntryI})

#endsub 

#for {EntryI = 1; EntryI <= 100; EntryI++} AddEntry