Search code examples
installationnsis

Show another license page after finish main installation part using NSIS


So, this is my current installer page structure:

!insertmacro MUI_PAGE_WELCOME
page custom CheckHWSpecs
!insertmacro MUI_PAGE_LICENSE "${SOURCEFOLDER}\CDA_update061702.txt"
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

When user finish installing the main application, I need to install a third-party application. Before start to install the 3rd-party app, I need to show another license page and if user agree, it will continue to install the app. But, if user disagree, it will cancel the 3rd-party app installation and the installation process is finish.

Can I do something like this?

!insertmacro MUI_PAGE_WELCOME
page custom CheckHWSpecs
!insertmacro MUI_PAGE_LICENSE "${SOURCEFOLDER}\CDA_update061702.txt"
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_LICENSE "${SOURCEFOLDER}\license2.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

But if there are two !insertmacro MUI_PAGE_INSTFILES, how to make sure the 3rd-party installer will run in the second MUI_PAGE_INSTFILES?


Solution

  • !include Sections.nsh
    !include WinMessages.nsh
    ShowInstDetails show
    !include MUI2.nsh
    !insertmacro MUI_PAGE_WELCOME
    !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Examples\example1.nsi"
    !insertmacro MUI_PAGE_INSTFILES
    !define MUI_LICENSEPAGE_CHECKBOX
    !define MUI_LICENSEPAGE_CHECKBOX_TEXT "Blah blah blah app and agree..."
    !define MUI_PAGE_CUSTOMFUNCTION_SHOW Lic2Show
    !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Examples\example2.nsi"
    !insertmacro MUI_PAGE_INSTFILES
    !insertmacro MUI_PAGE_FINISH
    !insertmacro MUI_LANGUAGE English
    
    Section /o "Bonus app" SID_BONUS
    DetailPrint "Installing bonus app..."
    Sleep 2222
    SectionEnd
    
    Section "Main app" SID_MAIN
    DetailPrint "Installing main app..."
    Sleep 2222
    
    !insertmacro SelectSection ${SID_BONUS}
    !insertmacro UnselectSection ${SID_MAIN}
    SectionEnd
    
    Function Lic2Show
    GetDlgItem $0 $hwndparent 2
    SendMessage $0 ${WM_SETTEXT} 0 "STR:$(MUI_BUTTONTEXT_FINISH)"
    FunctionEnd
    

    If the user does not install the extra app then you never get to the finish page, the cancel button is just renamed to "Finish".