简体   繁体   中英

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?

  • I would configure the 3rd -party app as another section (it can be hidden if the text is empty or by code with a SectionSetText ${SectionID} "" ).
  • After the first licence page, use a custom page to display the 2nd license with a checkbox to accept it (IIRC you can use only one MUI_PAGE_LICENSE )
  • depending on the result of the custom page (use a custom page leave callback to test for acceptance or not), check the hidden section with !insertmacro SelectSection ${SectionID}
  • then during the execution of MUI_PAGE_INSTFILES your 3rd-party app will be installed (or not) like the main app.
!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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM