Skip to content
⌘ NSIS Forum Archive

Choose components to install via Checkbox

3 posts

ascTim#

Choose components to install via Checkbox

Hey,

I am trying to create an installer by using checkboxes.
So I want a custom page with 4 Checkboxes which are checked by default and every checkbox should execute a different section if it's checked when you click "Install"

For now I got this far. Please tell me if that's correct or not. And how I can make it possible.

Page custom MyPage1
Function MyPage1
nsDialogs::Create 1018
!insertmacro MUI_HEADER_TEXT "Header Line" ""
Pop $0
${NSD_CreateLabel} 0 0 100% 10u "Bitte wählen Sie die zu installierenden Komponenten aus:"
Pop $0
${NSD_CreateCheckbox} 30 30 150 10u "Option1"
${NSD_CreateCheckbox} 30 55 150 10u "Option2"
${NSD_CreateCheckbox} 30 80 150 10u "Option3"
${NSD_CreateCheckbox} 30 105 150 10u "Option4"
nsDialogs::Show
FunctionEnd 
Anders#
Var MyCheckbox1
!include LogicLib.nsh
!include nsDialogs.nsh
!include sections.nsh
Page custom MyPage1 MyPage1Leave
Page InstFiles
Function MyPage1 
nsDialogs::Create 1018 
#!insertmacro MUI_HEADER_TEXT "Header Line" "" 
Pop $0 
${NSD_CreateLabel} 0 0 100% 10u "Bitte wählen Sie die zu installierenden Komponenten aus:" 
Pop $0 
${NSD_CreateCheckbox} 30 30 150 10u "Option1" 
Pop $MyCheckbox1
${NSD_Check} $MyCheckbox1 ; Optional
nsDialogs::Show 
FunctionEnd  
Section Sec1 SID_1
DetailPrint "Section1"
SectionEnd
Function MyPage1Leave
${NSD_GetState} $MyCheckbox1 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_1}
${Else}
    !insertmacro UnselectSection ${SID_1}
${EndIf}
FunctionEnd 
ascTim#
Hey Anders,

works brilliantly. I've added the other 3 checkboxes without any problem.

Thank you!
Have a great week 🙂