Skip to content
⌘ NSIS Forum Archive

unable to cancel installation in between installation process

8 posts

dhiraj3301#

unable to cancel installation in between installation process

Hi,

during installation,when i click cancel it shows pop up that "Do you want to exit the setup?"
but installation is going on in background,when i click on yes then the installer quits,but,i want to pause the installation when the popup "Do you want to exit the setup?" is showed.for that i have written following code.


!Define XPUI_ABORTWARNING_TEXT "Do you want to exit the setup?" IDYes quit

Function INSTFILELEAVE
strcmp $XPUI_ABORTED 1 0 +2
quit
FunctionEnd

Please tell me what to do to pause installation when the popup is active.
jpderuiter#
dhiraj3301#
this is not working properly,installation is not paused when the abort confirmation popup is opened,installation is still continue in background uptil when i have click on yes button.

Please tell me how to pause the installation.
Animaether#
Originally Posted by dhiraj3301 View Post
Please tell me how to pause the installation.
It's explained on that page - did you actually try?

OutFile "test.exe"
!include "xpui.nsh"
!include "LogicLib.nsh"
ShowInstDetails show
AutoCloseWIndow false
Var UserIsMakingAbortDecision
Function PauseIfUserIsMakingAbortDecision
  ${DoWhile} $UserIsMakingAbortDecision == "yes"
    DetailPrint "Waiting for user to make decision..."
    Sleep 500
  ${Loop}
FunctionEnd
!define PauseIfUserIsMakingAbortDecision `Call PauseIfUserIsMakingAbortDecision`
${Page} InstFiles
Section
  GetDlgItem $0 $HWNDPARENT 2
  EnableWindow $0 1
  DetailPrint "A"
  Sleep 1000
  ${PauseIfUserIsMakingAbortDecision}
  DetailPrint "B"
  Sleep 1000
  ${PauseIfUserIsMakingAbortDecision}
  DetailPrint "C"
SectionEnd
Function .onUserAbort
  StrCmp $NOABORTWARNING 1 AbortMe
  StrCpy $UserIsMakingAbortDecision "yes"
  MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure you want to cancel Setup?" IDNO NoAbort
  StrCpy $UserIsMakingAbortDecision "no"
  !insertmacro XPUI_USERABORT
  NoAbort:
  StrCpy $UserIsMakingAbortDecision "no"
  Abort
  AbortMe:
FunctionEnd
!insertmacro XPUI_LANGUAGE "English" 
This is only the pausing part. You'll want further code changes to handle things elegantly.. hence that page.
dhiraj3301#
this code works fine but i have used

!Define XPUI_ABORTWARNING
!Define XPUI_ABORTWARNING_TEXT "Do you want to exit the setup?"

so,i cannot use function .OnUserAbort,please tell me is there any way to pause installation when we are using !Define XPUI_ABORTWARNING .
Animaether#
Originally Posted by dhiraj3301 View Post
tell me is there any way to pause installation when we are using !Define XPUI_ABORTWARNING .
yes-and-no...

you'll have to create your own abort warning, just as in the above example and the examples on the wiki page.

it is possible that you could adjust the ExperienceUI header file to add the pause variable (ExperienceUI\Contrib\XPUI.nsh, just search for .onUserAbort); you'll still have to check for that pause variable in your sections, yourself, though.
Animaether#
Originally Posted by Afrow UK View Post
If it is anything like MUI it should have an MUI_CUSTOMFUNCTION_ABORT or similar define.
Doesn't seem to be. The only custom functions are for GUI init, GUI end and Pre/Show/Leave for pages. Defining XPUI_ABORTWARNING causes ExperienceUI to run its own .onUserAbort , which itself contains no code for handling additional user-based abort commands.

So setting up one's own .onUserAbort, and not using XPUI_ABORTWARNING, appears to be the road to take there.