Archive: How to run a program and wait till it finishes before an uninstall continues?


How to run a program and wait till it finishes before an uninstall continues?
I need to run a program before an uninstall completes. My application installs services onto the users system and an uninstall will not work as it can not delete any of the services in use.

I have a batch file which shuts down all the services... I need to call it and have it finish *before* the uninstall continues...

This should be possible I hope... Can someone please help me with this?

Thank you for any information on this :)


Use ExecWait.


I placed the Execwait command as the first command in the section "section uninstall". It seems to work like a charm. Wise?

Thank you Joost for this information :)


i would put execwait in the "Function un.onInit" - this is executed before all other uninstall stuff.


Thank you Brummelchen,

I previously had it at the top of the uninstall function call but it seems your method is just as good and will be my preferred method from now on. Thank you

Now I just have to get these executables to launch in minimized mode or appear not at all...

Thanks again :)


I looked further into the nsExec function and I think it works without displaying the dos box... I really hope so and this NSIS is getting cooler by the moment. Thank you to everyone for your help :)


Yes that is the whole point of nsExec, plus it allows you to capture output into the stack or to the details window!


Putting it in the section is better than using un.onInit, because:

1) It won't be executed if the user quits the uninstaller before uninstalling
2) There is a dialog when the user has to wait


@Joost

In that (1) point you're right - but look yourself what i did

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "<bla> would you like to uninstall '${MUI_PRODUCT}' and all its components?" IDYES +2
Abort
FunctionEnd


My first question in the uninstaller

(2) he is using something like execwait - there is no option to display a messagebox while waiting?
I have problems to understand inserting sections while using the MUI or InsertOptions to get messages.

Ok, but most people use a confirm page.

If you put it in a section, you will see the normal installation window (with details, information etc.).


So far I have ExecWait in the "un.onInit" function area below "Abort" and it seems to do its job pretty good. I've tested it with continuing ahead and in quitting the uninstall early by saying no.

It seems to so far work without problems. Joost are you referring to the nsExec command in the "un.onInit function area"? That is the command I would like to use but I have no real idea on how to get it to run for an uninstallation.

The nsExec will not run in either of the uninstall functions or section areas.

So far ExecWait seems to do its job *but* it is unable to do it with parameters to minimize or hide dos boxes like nsExec does. Is their a solution or a way to call nsExec for an uninstallation?

Thank you


What is the problem? nsExec should work.


This works using ExecWait in 2.0b3

Function un.onInit
MessageBox...
Abort
ExecWait "$INSTDIR\Core_Shut_Down.bat"
FunctionEnd

And this Works in 2.0b3
Section Uninstall
ExecWait "$INSTDIR\Core_Shut_Down.bat"
...


But neither of these work in regards to nsExec in 2.0b3
Function un.onInit
MessageBox...
Abort
nsExec::Exec "$INSTDIR\Core_Shut_Down.bat"
FunctionEnd

And neither does this work in 2.0b3
Section Uninstall
nsExec::Exec "$INSTDIR\Core_Shut_Down.bat"
...


Currently nsExec works in a section only during install but how do I tell uninstall to execute a section before going through with the uninstall? I am considering anything that works in either minimizing or hiding the dos boxes all together... Preferably nsExec.

Thank you Joost

Ok I just successfully tweaked my script so to be fully compliant with the latest dev build of 2.0b4. I will get to work on this. Thank you Everyone!