Archive: Cancelling during MUI_PAGE_INSTFILES


Cancelling during MUI_PAGE_INSTFILES
  The cancel buttons on the installer is grayed out when it it is installing files. Is it possible enable that? is there an option I don't know about for that?
Its one of our test center requirements that a user be able to cancel during install.


You can force the button to be enabled like this:

Section ""
GetDlgItem $0 $HWNDPARENT 2
EnableWindow $0 1
SectionEnd


But I doubt it will work properly...

Yeah, would be nice to get hitting that as a callback.


wouldn't that end up calling .onUserAbort (haven't tested), or its MUI equivalent?

If so, you could set a variable before InstFiles, then unset it after. Then in the user abort handler, check for that variable and if it is set, run special 'abort' code specific to aborting while installing files?


The problem is, that even if .onUserAbort is invoked, calling "Abort" in that function has a special meaning and would actually prevent the installer from aborting...


sure.. but perhaps you can check for a variable set in userAbort ( still not sure if it's invoked ;) ) in your sections before each File command and, if it's set, abort the section.. and any subsequent sections.


Looks like that should, at least in theory, work. Example code:


outFile "test2008Jul22.exe"


>var installingFiles
>var abortAbortAbort

Section
GetDlgItem$0 $HWNDPARENT 2
EnableWindow$0 1

StrCpy $installingFiles 1

messagebox MB_OK "Always trigger"

StrCpy $0 0
_again:
IntOp $0 $0 + 1
IntCmp$0 10 +3
sleep 250
goto _again

StrCmp $abortAbortAbort 1 _aborted
messagebox MB_OK "Only trigger if not aborted"
goto _skip
_aborted:
messagebox MB_OK "Only trigger if aborted"
_skip:
StrCpy $installingFiles 0
SectionEnd

>Function .onUserAbort
MessageBox MB_OK "onUserAbort called"
StrCmp $installingFiles 1 0 _skip
MessageBox MB_OK "onUserAbort called during instFiles"
StrCpy $abortAbortAbort 1
Abort
_skip:
>FunctionEnd
>
Edit: hmm not sure if it's a limit of messageboxes, but if you don't click through the .onUserAbort messageboxes quickly enough, the Section code will continue to run in the background, the timer will hit 10, and the script will continue to think it was not aborted. Easily fixed by moving the messageboxes around.. or not using them all, they're only there for debuggery/demonstration purposes.. but it does mean that the aborting may not be *instant* if the Section's File commands continue in the background as well. Extracting files should be a fair bit slower than setting that variable, though - but I've not tested. 3am here, not going to test it fully right now either :)

Tryed it
  Just tried to add such section on MUI2 based installer.
The cancel button is still dissabled.
Would be nice to enable the cancel button when installing, but it's not must have for my installer.


Old thread - just ran into it again (my topic watch stopped working somewhere along the timeline of life) and, after reading a more recent question asking the same thing, decided to give it another stab.

Results are in:
http://nsis.sourceforge.net/InstFile...ring_InstFiles
( InstFiles Cancel - Allowing a user to cancel installation during InstFiles )


Thank you for the article. Seems complex but will use it if I do some next NSIS based installer.


yep.. one wasn't meant to do this sort of thing with NSIS - the Cancel button was disabled on purpose, after all :)