在 NSIS 中卸载不同目录中的先前版本的方法是什么?
我正在调整 NSIS 安装程序以更好地处理非默认安装目录,但遇到了问题。
我的安装程序通过以下方式检查现有安装并调用现有卸载程序(如果有):
'"$OLD_INSTDIR\uninstall.exe" /S _?=$OLD_INSTDIR'
其中 $OLD_INSTDIR 是我创建的从注册表项填充的变量。这工作正常,但我一直在测试有人从现有安装所在位置更改安装目录的情况,并注意到卸载程序可执行文件和旧安装目录没有被删除。
经过一番挖掘后,我了解到 _?=$OLD_INSTDIR 参数会导致安装程序在其所在位置运行,而不是复制到临时目录。这可以解释为什么删除没有发生。
我尝试在卸载现有版本后显式删除卸载程序和目录,但这对我来说也不起作用。
ExecWait '$UNINSTALL_OLD_VERSION'
Delete $OLD_INSTDIR/uninstall.exe
RmDir $OLD_INSTDIR
关于我应该做什么有什么想法吗?如果这是一件微不足道的事情,我很抱歉,但我对 NSIS 的熟悉程度几乎仅限于从示例构建安装程序,然后再也不会接触它。
I'm tweaking an NSIS installer to better handle non-default install directories and I've hit a problem.
My installer checks for an existing install and calls the existing uninstaller if there is one via:
'"$OLD_INSTDIR\uninstall.exe" /S _?=$OLD_INSTDIR'
Where $OLD_INSTDIR is a Var I've created an populated from a registry entry. This works fine, but I've been testing the scenario where someone changes the install directory from where the existing install is and noticed that the uninstaller executable and the old install directory aren't deleted.
After a bit of digging, I understand that the _?=$OLD_INSTDIR parameter causes the installer to run where it is rather than getting copied to a temp directory. This would explain why the delete doesn't occur.
I've tried explicitly deleting the uninstaller and directory after the existing version is uninstalled, but this doesn't work for me either.
ExecWait '$UNINSTALL_OLD_VERSION'
Delete $OLD_INSTDIR/uninstall.exe
RmDir $OLD_INSTDIR
Any ideas on what I should be doing? Apologies if this is something trivial, but my familiarity with NSIS is pretty much limited to building the installer from examples and then never touching it again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
_?= 停止通常的复制到 %temp% 行为,但也防止卸载程序删除自身,因此您需要首先使用 _?参数然后删除卸载程序
_?= stops the usual copy to %temp% behavior, but also prevents the uninstaller from deleting itself, so you need to first run with the _? parameter and then delete the uninstaller