Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute an NSIS uninstaller from within an another NSIS installer and wait for it to finish?

Tags:

nsis

I have an installer, a compiled NSIS script and it first checks if another version of my application is running on the system. If another instance exists, then it first triggers the silent uninstallation and then proceeds with installation of the new intance.

I use ExecWait to trigger the unistaller in the silent mode but my main installer process does not wait and goes ahead with the installation process.

How do I force the main installer to wait for the silent uninstallation to complete first?

like image 919
user573696 Avatar asked Jan 13 '11 04:01

user573696


People also ask

How do you compile NSIS?

nsi file by simply right-clicking on it in Explorer and selecting 'compile'. If you want to use MakeNSIS on the command line, the syntax of makensis is: makensis [ option | script.

What is a NSIS script?

1.1 About NSIS NSIS (Nullsoft Scriptable Install System) is a tool that allows programmers to create such installers for Windows. It is released under an open source license and is completely free for any use.


2 Answers

There is a special uninstaller parameter you need to use (The reason for this is that normally the uninstaller needs to be able to delete itself)

ExecWait '"$INSTDIR\uninstaller.exe" /S _?=$INSTDIR'
like image 149
Anders Avatar answered Sep 21 '22 15:09

Anders


It is not just about "ExecWait". It is also about "_?", a special uninstaller instruction. Actually, during uninstall the uninstaller.exe is copied to a temp directory and then executed from there.

This step of copying and invoking a new uninstaller from temp directory might be fast and the call would come back immediately without actually waiting for the uninstaller to complete.

By using "_?" instruction you tell NSIS to run the uninstaller from the same place and not from the temp directory.

By using "ExecWait" in addition to the "_?" you tell NSIS to wait for the "uninstaller" process to complete and then return. This way you achieve what you need.

refer http://nsis.sourceforge.net/Docs/Chapter3.html#3.2.2 for more information.

like image 40
vikas pachisia Avatar answered Sep 24 '22 15:09

vikas pachisia