第二次安装相同版本的 windows 安装程序软件而不是静默安装时显示错误消息

When installing the same version of the windows installer software second time instead of silently installing it is showing the error message

我第一次安装了windows 安装程序软件,并且安装正确。 如果我从控制面板->Add/Remove 程序手动卸载软件,那么它正在安装而不显示任何错误消息。

在“卸载”部分,我写了下面的代码

Section "Uninstall"

  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Test"
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Test\EMR"
  DeleteRegKey HKLM "SOFTWARE\Test\EMR"
  DeleteRegKey HKLM "SOFTWARE\Test"

  ; Remove files and uninstaller
  Delete $INSTDIR\EMR_4.0.1.nsi
  Delete $INSTDIR\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$INSTDIR\Test\EMR\*.*"

  ; Remove directories used
  RMDir "$INSTDIR\Test\EMR"
  RMDir "$INSTDIR\Test"
  RMDir "$INSTDIR"

 RMDir /r /REBOOTOK $INSTDIR
SectionEnd

请帮我解决错误。

根据您的描述很难判断到底发生了什么,但这很可能是以下两种情况之一:

  • 文件正在使用中(在另一个程序中打开或 program/service 本身是 运行)。

  • 您没有对该文件的写入权限。通过设置 RequestExecutionLevel 属性确保安装程序是 UAC 提升的。