簡體   English   中英

在NSIS安裝程序中等待NSIS卸載程序完成或者失敗,或者將不會刪除該卸載程序

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

使用NSIS,我想在安裝新版本之前從安裝程序中調用以前安裝的版本的卸載程序。 建議的解決方案是執行以下命令:

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

據我了解,需要_?=$INSTDIR才能使ExecWait真正等待。 沒有它,NSIS會將卸載程序復制到temp目錄,在該目錄下啟動它,然后在卸載程序完成之前返回。 該解決方案的問題在於,卸載程序直接在$ INSTDIR中執行。 這導致卸載程序中的以下命令失敗:

Delete "$INSTDIR\uninstall.exe"

據我了解,未刪除uninstall.exe的原因是,無法刪除當前正在執行的文件。 總結一下我的問題:

ExecWait '"$INSTDIR\uninstall.exe"'

不等待卸載程序完成並且

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

不允許卸載程序刪除自己。 有人知道如何等待卸載程序完成,同時允許卸載程序在卸載過程中立即將其自身刪除嗎?

_?=參數告訴它應該自我復制到被卸載%temp%而無需等待它完成並執行該副本。 _?=之后的路徑用於在卸載程序中初始化$ InstDir。

在安裝程序中,您可以執行以下操作:

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