1
votes

I have a section in my installer I am attempting to make mandatory depending on some condition (the presence of a registry value) but I am not getting the behaviour I am expecting.

I am attempting to use the following command to make the section ticked and locked:

SectionIn RO

I also have a registry value that definitely exists but both of the following code chunks cause the section to be locked and ticked...

ClearErrors
ReadRegStr $0 HKCU "Software\Test" "TestValue"
${If} ${Errors}
    SectionIn RO ; registry key not found
${Else}
    ; do nothing
${EndIf}
ClearErrors
ReadRegStr $0 HKCU "Software\Test" "TestValue"
${If} ${Errors}
    ; do nothing
${Else}
    SectionIn RO ; registry key was found
${EndIf}

So it seems like either both control paths are being executed or the SectionIn command is trancending the if logic.

I can't seem to find much documentation on this particular command but I am a bit stumped. Any ideas?

1

1 Answers

2
votes

SectionIn is an attribute and cannot be changed at run-time.

You should use the section helper macros in .onInit:

Section "blah" S_1
SectionEnd

!include LogicLib.nsh
!include Sections.nsh
Function .onInit
 ... 
${If} ${Errors} 
  !insertmacro SetSectionFlag ${S_1} ${SF_RO} 
${EndIf} 
FunctionEnd