views:

285

answers:

2

Setup programs created with Inno Setup could read an INI file through /LOADINF option. Is it possible to read custom variables through this INI file? Is there a function to get the name of the INI file given with this option? (Then it is possible with the INI utility functions.)

+1  A: 

We simply iterate over the commandline arguments using the ParamStr(i) function and look for an argument starting with "/LOADINF=" and then extract the file name from there.

One gotcha that got us initially was that the file name might be a relative path descriptor (e.g. just the file name). However, if you use compression then the current working directory will be some sub-folder in your %TEMP% folder rather than the directory where your setup.exe is. You should therefore make sure to detect this and prepend the given file name with AddBackslash(ExpandConstant('{src}')) if necessary.

Oliver Giesen
A: 

The code

ExpandConstant('{param:LoadInf}')

provides the file INI file name from the command line parameters.

Use this code if the INF file is in the setup folder

AddBackslash(ExpandConstant('{src}')) + ExpandConstant('{param:LoadInf}');
s01ipsist