Nif*_*fle 10 installer nsis uninstallation
我刚开始使用NSIS.
它工作得很好,但我发现文档有点非结构化.在使用NSIS安装新版本之前,如何要求用户卸载以前的版本?
NSIS(Nullsoft Scriptable Install System)是一个用于创建Windows安装程序的开源系统.
spi*_*n_g 13
NSIS是一个出色的Windows安装程序.以下是我在安装同一应用程序的新版本时使用NSIS卸载当前版本的方法.将以下函数添加到NSIS脚本中.
Function .onInit
Exec $INSTDIR\uninst.exe
FunctionEnd
Run Code Online (Sandbox Code Playgroud)
你还可以检查出这对"自动卸载安装新先老"的NSIS维基链接.
cdm*_*kay 13
另一种方法是创建一个UninstallPrevious隐藏的部分,并使其在安装程序中的所有其他部分之前运行.我还建议让卸载程序默默运行.
; The "" makes the section hidden.
Section "" SecUninstallPrevious
Call UninstallPrevious
SectionEnd
Function UninstallPrevious
; Check for uninstaller.
ReadRegStr $R0 HKLM "${HKLM_REG_KEY}" "InstallDir"
${If} $R0 == ""
Goto Done
${EndIf}
DetailPrint "Removing previous installation."
; Run the uninstaller silently.
ExecWait '"$R0\Uninstall.exe /S"'
Done:
FunctionEnd
Run Code Online (Sandbox Code Playgroud)
这种方法的优点是用户在准备安装新版本之前不会卸载旧版本.此外,他们甚至不必做出卸载旧版本的决定,它只是神奇地消失了.
当然,根据您的需要,您可能希望用户确认卸载,在这种情况下使用spinner_den的方法.