1

我是 NSIS 的新手,但是我想在安装新版本时检查现有安装的旧版本。我所做的和我在这里找到的完全一样 - http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new但是因为我需要检查是否安装了旧版本才能正确进行卸载,所以我在安装进度中添加了 InstallLocation 注册表值。

如果我使用 ExecWait '$R0 _?=$INSTDIR' 并且旧版本的安装文件夹与 INSTDIR 相同,则一切正常。但是如果我使用 ExecWait '$R0 _?=$R1' 它会给我 NSIS 安装程序错误,但我就是找不到问题所在,我做错了什么?

有人可以帮忙吗?谢谢


注册表由此添加:


  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" "InstallLocation" '"$INSTDIR"'

函数代码:


ReadRegStr $R0 HKLM \
 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" \
 "UninstallString"

  StrCmp $R0 "" done

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
    "${AppName} is already installed. $\n$\nClick OK to remove the \
    previous version or Cancel to cancel the installation." \
IDOK uninst
Abort

;Run the uninstaller
uninst:
   ReadRegStr $R1 HKLM \
   "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" \
   "InstallLocation"

    ClearErrors
    HideWindow
    ClearErrors
    ExecWait '$R0 _?=$R1'
    BringToFront

done:
functionEnd
4

1 回答 1

2

您正在InstallLocation用引号编写路径,在执行安装程序之前不要这样做或去掉代码中的引号......

于 2013-08-06T23:09:51.197 回答