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
Abort behaviour
13 posts
Function .onAbort
# Your code here
FunctionEnd
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
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
It looks like it's supposed to be .onUserAbort. I don't see a .onAbort listed anywhere.
but .onUserAbort only seems to be fired when the abort process is cancelled by the user, not during the install itself
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).
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).
Again though using the script i posted earlier, but replacing .onAbort with .onInstFailed this is only triggered when cancel is pressed
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
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
Again though using the script i posted earlier, but replacing .onAbort with .onInstFailed this is only triggered when cancel is pressedSorry 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.
Abort takes a parameter that is displayed to the user.
Abort "installation aborted: couldn't find pickles"
It is the behaviour of the File command, which causes an abort if it is unable to write to the file system.
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.
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
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