开发者

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

开发者 https://www.devze.com 2023-02-04 16:36 出处:网络
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 sil

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?


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'


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号