Archive: Path,Version, Name...multible installers


Path,Version, Name...multible installers
I´m trying to read from a Ini File and then define this string. Easier to understand with some code:

!define NAME $Name
!define VERSION $Version
!define InstallDirectory $customINSTDIR
...
Name "${NAME} ${VERSION}"
InstallDir "$customINSTDIR"
...

Thats in my .nsh file which I include in a main installer and another installer which is executed from the main one. In the main installer I call:

Function .onInit
ReadINIStr $Name "$EXEDIR\Settings.ini" "Settings" "Product_Name"
ReadINIStr $Version "$EXEDIR\Settings.ini" "Settings" "Product_Version"
ReadINIStr $customINSTDIR "$EXEDIR\Settings.ini" "Settings" "Install_Path"
//StrCpy $Instdir $customINSTDIR ;I need this one to set the Instdir

FunctionEnd

My questions is why the variables are not set in other installer which have the same .nsh file? And why do I have to use strcpy in the .oninit function to set the Instdir?
Name and Version are with a !define so it should be set like a constant and when I call other installers they should see this variable right?


The other installer may be set to use the variable, but the variable will have no contents. You need to read the ini in the second installer as well.

As for why you need to strcpy $instdir, perhaps you're using an installdirregkey command somewhere? Anyway, you should probably use $instdir directly, no need to use a separate variable for that:
ReadINIStr $INSTDIR "$EXEDIR\Settings.ini" "Settings" "Install_Path"


But what if I change the INSTDIR...
Then I´ll have to change the ini str read it in the other installers...

The best way would it be if Name and Version would be set so I can use them in the other installers. (Without reading the ini)


There are several ways you can pass information to the second installer. None of them are automatic (almost nothing in NSIS is).

- Write to ini or registry before starting second installer
- Use commandline parameters (see http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.11 )
- Use FileWriteByte to append info to the second installer (comedy option)