Archive: InstallDir


InstallDir
I am trying to change the InstallDir variable when a new selection is made in a section. When I select a component to install I check a registry entry and get the install directory which is different for each component. I want to then display the install directory in the directory page. In the section I do a ReadRegKey and get the install directory but I dont know how to change it in the directory page to the entry I just got. Does anyone know how to do this?


Read directly to $INSTDIR.

Stu


Thanks,
I tried that but after I choose the component to install and then in the section I read the reg key into $INSTDIR and it still shows the default value InstallDir. Am I missing something? When does the processing take place for each section, before or after the directory page is called?


There's a script that I've done which may help you, here's a snippet:

OutFile "test.exe"
ShowInstDetails show
InstallDir "$PROGRAMFILES\My Application"

Page components
page directory
page instfiles

!include "Sections.nsh"
!include "logiclib.nsh"

Section /o "Install NSIS plugin" sec1
DetailPrint "Installing NSIS plugin (sec1)"
SectionEnd

Section /o "Install Firefox plugin" sec2
DetailPrint "Installing Firefox plugin (sec2)"
SectionEnd

Function .onSelChange
!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${sec1}
!insertmacro RadioButton ${sec2}
!insertmacro EndRadioButtons

SectionGetFlags ${sec1} $R0
IntOp $R0 $R0 & ${SF_SELECTED}

${If} $R0 = ${SF_SELECTED}
ReadRegStr $R0 HKLM "Software\NSIS" ""
StrCpy $INSTDIR "$R0\Plugins\My Plugin"
${EndIf}

SectionGetFlags ${sec2} $R0
IntOp $R0 $R0 & ${SF_SELECTED}

${If} $R0 = ${SF_SELECTED}
ReadRegStr $R0 HKLM "Software\Mozilla\Mozilla Firefox" "CurrentVersion"
ReadRegStr $R0 HKLM "Software\Mozilla\Mozilla Firefox\$R0\Main" "Install Directory"
StrCpy $INSTDIR "$R0\Plugins\My Plugin"
${EndIf}
FunctionEnd