thelliez
16th March 2004 23:40 UTC
Compile time: reading value from a .ini file
Trying to write a generic installer for different flavors of a product, I would like to have the name of the compiled installer to reflect few options (like a build number).
For example, instead of setup.exe, I would like something like setup_123.exe where 123 is a dynamic string available in a .ini file (built from an ant/cvs script).
If I could do some sort of ReadINIStr at compile time I would be set.
I guess I could try passing parameters to the compiler but it would not be as convenient.
Suggestions?
Thierry
Vytautas
17th March 2004 01:41 UTC
You will have to create a 'wrapper' installer using NSIS or any other programming language, then call that wrapper from your nsis script using the '!system' command. This wrapper should read your ini file(s) and either define the required defines automatically or generate an include file which can then be included into the script.
Vytautas
rainwater
17th March 2004 03:29 UTC
How about building a config.nsh file that !define's the properties? Otherwise, if you are forced to read a certain ini, then you will need to do what Vytautas said.
tolan
30th November 2006 07:56 UTC
You may use some bat magic :)
My solution (tested on WinXP):
!tempfile VAR_FILE
!system '@for /f "eol=# delims== tokens=1,2" %i in (ini_file.ini) do @echo ^!define "%i" "%j" >> "${VAR_FILE}"'
!include "${VAR_FILE}"
!delfile "${VAR_FILE}"
!undef VAR_FILE
Hope this helps.