Search code examples
nsis

Detect setup cancel on NSIS license page


I am trying to detect user canceling setup at the license page. I have tried Function .onInstFailed but it is only invoked when installation is aborted further down the chain. It is not triggered when user cancels on the license page. Is this doable? Here is the top of my script. licleave function is called only upon hitting I Agree.

!include nsdialogs.nsh
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE licleave
!insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Solution

  • You can define your own MUI_CUSTOMFUNCTION_ABORT function to process the page cancel.

    As suggested in that NSIS forum thread, you could set a flag to 1 when entering the license page, and set it to 0 when leaving the page.

    In the abort callback, test the flag: if set then you just canceling the license page.