seven24
18th March 2008 06:05 UTC
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?
Afrow UK
18th March 2008 14:44 UTC
Read directly to $INSTDIR.
Stu
seven24
19th March 2008 00:28 UTC
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?
Red Wine
19th March 2008 15:54 UTC
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