Search code examples
nsis

Open custom page from within section?


I am putting together my first NSIS installer script, and having some trouble.

I am using Modern UI and have provided a simplified script below:

!insertmacro MUI_PAGE_COMPONENTS
Page custom CustomPage

Section "Tomcat" SEC01  
;stuff in here to install Tomcat from bundled installer  
SectionEnd

Section "Deploy WARS" SEC02  
;Fire a separate custom page so that I can use nsDialog to get
;user to choose a folder location for deploying WARs.
;(as potentially their could be more than one Tomcat installed) 
SectionEnd

From what I have read, you cannot fire a custom page from within a section.
So how can I maintain the MUI_PAGE_COMPONENTS page to allows user to choose on if they want to install Tomcat AND/OR also deploy WARs.

I will def need a custom page right?


Solution

  • You can have more than one instfiles page so you could have a installer with this page order:

    1. Components
    2. InstFiles (Installs Tomcat)
    3. Directory (Choose WAR destination)
    4. InstFiles (Install WAR)

     

    Section "Tomcat" SECTOM
    SectionEnd
    Section /o "WAR" SECWAR
    SectionEnd
    Section
    ;Use macros from sections.nsh to deselect SECTOM and select SECWAR
    SectionEnd
    

    The pre callback functions for page 3 and 4 need to use SectionFlagIsSet from sections.nsh and call Abort if the War component was not selected so the pages are skipped.


    Another alternative is to try the DlgHost plugin and show the custom dialog in a child window on your instfiles page...