简体   繁体   English

在NSIS安装程序中等待NSIS卸载程序完成或者失败,或者将不会删除该卸载程序

[英]Waiting for NSIS uninstaller to finish in NSIS installer either fails or the uninstaller won't be deleted

Using NSIS, I want to call the uninstaller of a previously installed version from my installer before installing the new version. 使用NSIS,我想在安装新版本之前从安装程序中调用以前安装的版本的卸载程序。 The proposed solution for this is to execute the following command: 建议的解决方案是执行以下命令:

ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR'

As far as I understood, the _?=$INSTDIR is needed to make the ExecWait truly waiting. 据我了解,需要_?=$INSTDIR才能使ExecWait真正等待。 Without it, NSIS would copy the uninstaller to the temp directory, start it there, and then return before the uninstaller finishes. 没有它,NSIS会将卸载程序复制到temp目录,在该目录下启动它,然后在卸载程序完成之前返回。 The problem with this solution is, that the uninstaller is directly executed in the $INSTDIR. 该解决方案的问题在于,卸载程序直接在$ INSTDIR中执行。 This leads to the effect that the following command in my uninstaller fails: 这导致卸载程序中的以下命令失败:

Delete "$INSTDIR\uninstall.exe"

As far as I understood, the reason why uninstall.exe is not deleted is, that a file which is currently being executed cannot be deleted. 据我了解,未删除uninstall.exe的原因是,无法删除当前正在执行的文件。 To summarize my problem: 总结一下我的问题:

ExecWait '"$INSTDIR\uninstall.exe"'

doesn't wait for the uninstaller to finish and 不等待卸载程序完成并且

ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR'

doesn't allow the uninstaller to delete itself. 不允许卸载程序删除自己。 Does anybody know, how to wait for an uninstaller to finish while at the same time allowing the uninstaller to instantly delete itself within the uninstallation process? 有人知道如何等待卸载程序完成,同时允许卸载程序在卸载过程中立即将其自身删除吗?

The _?= parameter tells the uninstaller that it should not copy itself to %temp% and execute that copy without waiting for it to complete. _?=参数告诉它应该自我复制到被卸载%temp%而无需等待它完成并执行该副本。 The path after _?= is used to initialize $InstDir in the uninstaller. _?=之后的路径用于在卸载程序中初始化$ InstDir。

In your installer you can do something like this: 在安装程序中,您可以执行以下操作:

InitPluginsDir
;ReadRegStr $oldinstall ... ; Somehow detect old install
CreateDirectory "$pluginsdir\unold" ; Make sure plugins do not conflict with a old uninstaller 
CopyFiles /SILENT /FILESONLY "$oldinstall\uninst.exe" "$pluginsdir\unold"
ExecWait '"$pluginsdir\unold\uninst.exe" _?=$oldinstall'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM