In an Inno Setup script, I need to copy a number of files to multiple user-defined locations. In order to do this, I'd like to iterate over the sources in the [Files]
section, and FileCopy()
them multiple times depending on the user-defined settings and properties of the files.
Is it possible to access the sources in the [Files]
section using a script?
No, you cannot iterate the
[Files]
section.But you can use preprocessor to generate both the
[Files]
section and the Pascal Script from one list of files.You are not very specific about your goals, so I'm showing only a rough concept.
If you compile the script, you can see in the preprocessed file
Preprocessed.iss
that it generates this:Actually you may not need to use the
FileCopy
for this specific purpose. You can just have the preprocessor generate multiple[Files]
section entries for the same file:Generates:
Inno Setup will identify identical source files and will pack them only once.
You can use
Check
parameter to make some entries conditional.See also this question, which is actually similar:
Access file list via script in InnoSetup