【问题标题】:Making installer/reinstaller in NSIS在 NSIS 中制作安装程序/重新安装程序
【发布时间】:2015-06-12 20:02:34
【问题描述】:

我需要这个例程 - 如果提供带有安装路径的 RegKey,我们必须停止执行的应用程序(如果已执行),静默启动卸载程序(如果未找到卸载程序 - 只需删除目录中的所有文件)并将 INSTDIR 设置为值从注册表。 如果带有安装路径的 RegKEY 不存在 - 开始正常安装。

; Try to read Install Path from Reg
ReadRegStr $0 HKCU "Software\TelnetTray" "Path"

; Uninstall first if app installed
${If} $0 != ""
  !define INSTDIR $0

  ; Try to stop app if executed
  Stop "$INSTDIR\app.exe"

  ; Try to uninstall
  ${If} ${FIleExists} "$INSTDIR\uninst.exe"
    ExecWait "$INSTDIR\uninst.exe /S"
  ; Or just delete all files in INSTDIR
  ${Else}
    Delete "$INSTDIR\*"
  ${EndIf}
${EndIf}

【问题讨论】:

    标签: nsis


    【解决方案1】:

    你几乎明白了

    ; Try to read Install Path from Reg
    ReadRegStr $0 HKCU "Software\TelnetTray" "Path"
    
    ; Uninstall first if app installed
    ${If} $0 != ""
      StrCpy $INSTDIR $0
    
      ; Try to stop app if executed
      ${nsProcess::CloseProcess} "$INSTDIR\app.exe" $R0
    
      ; Try to uninstall
      ${If} ${FIleExists} "$INSTDIR\uninst.exe"
        ExecWait "$INSTDIR\uninst.exe /S"
      ; Or just delete all files in INSTDIR
      ${Else}
        RMDir /r "$INSTDIR"
      ${EndIf}
    ${EndIf}
    

    【讨论】:

    • 你不能这样做!定义 INSTDIR $0 然后像那样使用 $INSTDIR!
    • 谢谢@Anders!我注意到原始帖子上的错误,但忘记更正了。固定。
    猜你喜欢
    • 2014-08-30
    • 2012-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-02
    • 1970-01-01
    相关资源
    最近更新 更多