我正在使用 NSIS 为我的应用程序创建一个设置,并且需要检查它是否已经安装:
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "MyAppInstaller.exe"
InstallDir "$PROGRAMFILES\MyApp"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Function .onInit
; Check to see if already installed
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME} ${PRODUCT_VERSION}" "UninstallString"
IfFileExists $R0 +1 NotInstalled
Messagebox MB_ICONQUESTION|MB_YESNO "MyApp 1.0 is already installed.Do you want to uninstall old version" IDNO Quit
Exec $R0
Quit:
Quit
NotInstalled:
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd ...
但是什么也没发生它总是继续安装并且没有检测到旧的安装版本,我错过了什么吗?我对 NSIS 脚本了解不多,因此将不胜感激。