Archive: Why doesn't this 12-line script exit?! :P


Why doesn't this 12-line script exit?! :P
  Hello,

I don't understand why this script won't cause the installer to exit... 'Abort' has been used, and so has 'AutoCloseWindow true'.

Name "Abort from Section"

>OutFile "Abort.exe"
>ShowInstDetails nevershow
AutoCloseWindow true
Page instfiles

Section "blah"
>MessageBox MB_OK "Section blah"
>Abort "shouldn't this quit?"
>SectionEnd

>Function .onInstSuccess
MessageBox MB_OK "exiting"
>FunctionEnd
>
Looking forward to the answer to this mystery. ;) (Using latest dev snapshot.)

Salaam/Peace.

(P.S. I know about the 'Quit' command, I want to know why the above script doesn't create an installer that automatically closes - thanks.)

maybe this:


Name "Abort from Section"
OutFile "Abort.exe"
ShowInstDetails nevershow
AutoCloseWindow true
Page instfiles

Section "blah"
MessageBox MB_OK "Section blah"
Abort
SectionEnd

Function .onInstSuccess
MessageBox MB_OK "exiting"
Abort
FunctionEnd

Thanks Dark Boy, but that doesn't work. (Did it it work in your version of NSIS?)

The Abort command is allowed to take a parameter. From the docs:


Abort user_message

Cancels the install
, stops execution of script, and displays
user_message in the status display.
>Note: you can use this from Callback functions to do special things.
>Page callbacks also uses Abort for special purposes.
And after calling Abort from the Section, .onInstSuccess never gets called anyway... so the Abort you added to .onInstSuccess never runs.

thanks for trying to help though, i appreciate it. :)

Read the info you just posted, it aborts the install.

Use Quit to exit immidiately.


oh, right. :P

i misinterpreted


stops execution of script 

>
as, stops execution period.

thanks for pointing that out Joost.

(And thanks for your work on Modern UI & other stuff. :) )

Salaam/Peace.

so ... if i get 50% through my install, and then i do an abort (well, it seems like i should do a quit?) ... do i have to manually roll back any changes made up to that point?


But it is recommended. A great suggestion for rollback occasions:

You can put a "IntOp" command for each "File" command and each command that you know, will affect the user's system, like registry entries. And when the installator fails or a command abort is executed, it uses the callback function .onInstFailed. Inside this function, put i.e.:


#Total number of files 21:

IntCmp $0 20 0 0 +2
Delete "blablabla.txt"

IntCmp $0 19 0 0 +2
Delete "blablabla.exe"

IntCmp $0 18 0 0 +2
DeleteRegValue HKLM "Software\Your Program" "Install Dir"


$0 is the variable you put the amount of commands to reverse.
20, 19 and 18 numbers - if have a problem with the file #20 and abort, will do the reverse operations of the installation commands #20 to #1.

So will be a "LIKE" the real installation rollback.

:)

That is indeed a great suggestion. :) Thanks.