Skip to content
⌘ NSIS Forum Archive

SectionSetFlags clears all sections

12 posts

l201#

SectionSetFlags clears all sections

I'm trying to make my installer suitable for a silent option and therefor are enabling some commandline parameters to set/unset certain sections...

However, when I try to set a section in the onInit function, all my checkboxes are unchecked, including the one's who I try to check...

Te reproduce this problem, I made a small test project with just the code below... as soon as I run it, the installer will go the de 'Custom' option, but no checkbox is selected, while I do have two of them set....
!include "MUI.nsh"

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "English"

Name "NSIS-Test"
OutFile "Setup.exe"

InstType "Normal" ;1
InstType "Full" ;2

Section "MainSection" SEC01
SectionIn 1 2
SectionEnd

Section /o "SubSection2" SEC02
SectionIn 2
SectionEnd

Section /o "SubSection3" SEC03
SectionIn 2
SectionEnd

Function .onInit
SectionSetFlags ${SEC01} SF_SELECTED
SectionSetFlags ${SEC02} SF_SELECTED
SectionSetFlags ${SEC03} 0
FunctionEnd
What am i doing wrong?? According to the documentation of SectionSetFlags it's all correct, but why won't it be set?
I'm running version 2.46 btw...
Anders#
!include sections.nsh
SectionSetFlags ${SEC01} ${SF_SELECTED}
...but you really should use the helper macros in sections.nsh because the section flag is not a simple on/off flag.
l201#
Well... Basically I was using the helper macro (SelectSection) but as that wasn't working I was bringing it down to a more basic version to see which function was removing all my checkboxes... And when commenting out the SectionSetFlags in the macro, my checkboxes still exists.. But as soon as I called the macro once, all checkboxes where gone..

And therefor I stripped my version to current one, in which I used the SectionSetFlags directely
l201#
Please see attached two screenshots...

Running the installer just as defined in the code you see in both of them... Simply commenting out one line of code made all checkboxes checked or not..

[edit]
And just to be completed... I've inclued snapshots when using the macro function as well (3 and 4) and how it looks when I disable all selections in code (5)
henrikor2#
Why use both optional section markers (/o) and InstType's at the same time? Ain't they mutually exclusive?
l201#
It doesn't matter if I use InstType or not.. In my own project I'm not using it at all.. but in this sample project I was trying to figure out if that would solve my issue... But if I remove the InstType "Normal" and InstType "Full" and the SectionIn code rules as well, the behaviour is the same...

And by the way.. It looks like they are not mutually exclusive.. When I omit the /o in subsection2, the InstType will automatically switch to Custom
l201#
To make it easier again, I made a new screenshot... i removed the InstType and SectionIn code... In the onInit I only call 2 macro's so bases on this code, I would expect only MainSection and SubSection2 selected, but none of them was selected
henrikor2#
Are you sure you compiled it? The code is flawless and it should have the first two sections enabled. Or are there some limitations when using v2.46?
l201#
I definetily compiled it!! Struggling with it 2 days already, so this isn't just a thing of 5 minutes trying and forgetting to compile!

@Anders... did you compile it on commandline? And if so, with any additional parameters as well?? By default I'm running in HM NIS Edit, but also when I switch to commandline with just 'makensis test.nsi' it won't work....

I'm installing nsis 2.46 on another machine right now.. see what that one does...
l201#
Well... It looks like there was a corruption in my installation? Running the script on another pc did work indeed.. So I removed NSIS en reinstalled it again on my development machine, and then it succeeded as well.. And my original script is working too, so problem solved.... 😉
Thanks a lot guys!
Anders#
I have also added more checks to the compiler and the next version will not allow SectionSetFlags ${SEC01} SF_SELECTED, the parameters now have to be a variable or a number...