- NSIS Discussion
- Abort behaviour
Archive: Abort behaviour
sfranklin
8th October 2004 11:40 UTC
Abort behaviour
Hi,
Is there any way to change the default abort behaviour. At the moment i have an installer that takes some time to complete. If there is a problem coppying files using the file command, the install aborts. However it isnt clear this has happened, is there anyway of changing this, so that for example i could pop up a message box?
Thanks
Steve
deguix
8th October 2004 12:31 UTC
Function .onAbort
# Your code here
FunctionEnd
sfranklin
8th October 2004 13:06 UTC
Ive tried that, unfortunatly it doesnt seem to work, find below a simple script to demonstrate:
Name "Bannana"
OutFile "C:\Work_in_Progress\nsisTests\inst1.exe"
InstallDir c:\bannana
Function ".onInit"
FunctionEnd
Page directory
Page instfiles
Function .onAbort
MessageBox MB_OK "Install failed"
FunctionEnd
Section "Installing"
Sleep 1000
Abort
SectionEnd
ive also looked into the other callbacks, but i can only seem to trigger a callback when the user clicks cancel.
Steve
scully13
8th October 2004 14:08 UTC
It looks like it's supposed to be .onUserAbort. I don't see a .onAbort listed anywhere.
sfranklin
8th October 2004 14:15 UTC
but .onUserAbort only seems to be fired when the abort process is cancelled by the user, not during the install itself
scully13
8th October 2004 14:20 UTC
I think maybe what you want then is .onInstFailed. From the docs it says:
This callback is called when the user hits the 'cancel' button after the install has failed (if it could not extract a file, or the install script used the Abort command).
sfranklin
8th October 2004 15:48 UTC
Again though using the script i posted earlier, but replacing .onAbort with .onInstFailed this is only triggered when cancel is pressed
scully13
8th October 2004 15:59 UTC
How about this?
Section "Installing"
ClearErrors
CopyFiles /SILENT "$EXEDIR\nothing.exe" "$EXEDIR"
IfErrors Failer
;Copy other files checking for Errors between each.
Goto Good
Failer:
MessageBox MB_OK "Install failed"
Abort
Good:
SectionEnd
deguix
8th October 2004 19:47 UTC
Again though using the script i posted earlier, but replacing .onAbort with .onInstFailed this is only triggered when cancel is pressed
Sorry for the .onAbort thing, I meant .onUserAbort. At that time I was hurrying...
I suggest you to use:
1) a hidden section (about what scully13 suggested).
OR
2)
Function .onGUIEnd which will appear when the GUI is terminated.
kichik
10th October 2004 15:19 UTC
Abort takes a parameter that is displayed to the user.
Abort "installation aborted: couldn't find pickles"
sfranklin
11th October 2004 09:20 UTC
It is the behaviour of the File command, which causes an abort if it is unable to write to the file system.
kichik
11th October 2004 11:40 UTC
In that case, IfAbort in the leave funciton of the instfiles page is what you are looking for. That's what the MUI uses to update the header.
sfranklin
11th October 2004 11:55 UTC
Excellent, thats what i need, thanks.
For anybody else who needs something similar, before the instfiles page is added i added the line
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE instLeft
and defined the function instLeft as
Function instLeft
ifAbort +1 skip
MessageBox MB_OK "Looks like this wont work"
skip:
FunctionEnd
Thanks again all