【问题标题】:Uninstall old version before installing new在安装新版本之前卸载旧版本
【发布时间】:2013-08-06 14:20:59
【问题描述】:

我是 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

【问题讨论】:

    标签: nsis


    【解决方案1】:

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

    【讨论】:

    • 很抱歉,您能告诉我应该在哪里删除这些引号吗?我不明白。
    • '"$INSTDIR"',在 WriteRegStr 调用中或在 ReadRegStr 之后使用 strcmp+strcpy
    猜你喜欢
    • 2017-01-07
    • 2014-06-03
    • 1970-01-01
    • 2021-05-24
    • 1970-01-01
    • 2016-12-28
    • 2014-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多