Archive: Totally disabling a Section when installed.


Totally disabling a Section when installed.
I have an installer where the user can choose among several Sections, arranged in Groups.

All Sections and Groups are optional by default (unchecked).

Now, the thing is that with my installer, if the user chooses not to install a couple of the options and/or Groups the first time, he/she can re-open the installer later and add those features.

When the user re-opens the installer, I have made it so that the Sections and Groups that the user installed, are not visible on the Components page anymore. So the user can then only choose among the visible Sections/Groups, in other words the ones that weren't installed last time.

I have done this by using UnSelectSecion and SecionSetText [Section] "".

However - from practical tests:

-If the user has installed let's say all but one component from a Group, and he/she then later re-opens the installer, and uses the Group's main checkbox to select the remaining option within the Group, then NSIS runs even the Sections that are invisible.

If the user checks only the checkbox of the remaining Section within the Group (and don't use the Group's main checkbox), then it works, and only that last, visible Section is run.

Here's how my "Group/Section disabling and invisible making" code looks (there's one for each Group):

[edited]-I first put in the wrong code...[/edited]


ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "21"
${if} $0 == 1
!insertmacro UnselectSection ${Sec21}
SectionSetText ${Sec21} ""
${endif}

ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "22"
${if} $0 == 1
!insertmacro UnselectSection ${Sec22}
SectionSetText ${Sec22} ""
${endif}

ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "23"
${if} $0 == 1
!insertmacro UnselectSection ${Sec23}
SectionSetText ${Sec23} ""
${endif}

ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "24"
${if} $0 == 1
!insertmacro UnselectSection ${Sec24}
SectionSetText ${Sec24} ""
${endif}

ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "25"
${if} $0 == 1
!insertmacro UnselectSection ${Sec25}
SectionSetText ${Sec25} ""
${endif}

ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "21"
${if} $0 == 1
ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "22"
${if} $0 == 1
ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "23"
${if} $0 == 1
ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "24"
${if} $0 == 1
ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "25"
${if} $0 == 1
!insertmacro UnselectSection ${SubSecMisc}
SectionSetText ${SubSecMisc} ""
${endif}
${endif}
${endif}
${endif}
${endif}


(the meaning of the code above is that if the individual Section is installed, then it will be invisible in the installer, and if all the Sections within the Group are installed, then the entire Section Group will be invisible)


The reason I know that the invisible Components are run when you check their Group's main checkbox, is that stuff happens during install that isn't supposed to happen, when you check that main checkbox (because what happens is part of the invisible Components), and it doesn't happen if you check only the remaining Component's own checkbox instead.


How can I make sure that the invisible Sections/Components within a Group are not run when the user checks the main checkbox of the Group?

Is there such a thing as DisableSection or similar?

Thanks.

You need to make the section read only. This way user can't change the status.

        ReadRegStr $0 HKLM "Software\${PRODUCT_NAME}\InstallSections" "21"
${if} $0 == 1
!insertmacro SetSectionFlag ${Sec21} ${SF_RO}
!insertmacro UnselectSection ${Sec21}
SectionSetText ${Sec21} ""
${endif}
...