安装用NSIS开发的软件,在服务器操作系统安装怎么弹窗

When installing the software that was developed using NSIS, how should I throw a pop-up message if installing in server operating systems

安装使用NSIS开发的软件,在服务器操作系统安装时,如何弹窗?

以下是不支持的操作系统。在安装软件时,我应该显示弹出消息。

Windows Server 2003 
Windows Server 2003 R2
Windows Server 2008
Windows Server 2008 R2 
Windows Server 2012 
Windows Server 2012 R2

我很难实现这个。有人可以指导我吗?

您可以使用 WinVer.nsh 检测 Windows 个版本

!include "LogicLib.nsh"    
!include "WinVer.nsh"

Function .onInit
    ${If} ${IsServerOS}
        MessageBox MB_OK "Running on Windows Server."
        Quit
    ${EndIf}
FunctionEnd

如果您需要更具体,您可以将其与 AtLeastWin* / AtMostWin* 结合使用,其中 * 是您定位的版本(例如 AtLeastWin2003 / AtLeastWin2012R2)

使用WinVer.nsh检测Windows版本:

!include WinVer.nsh
!include LogicLib.nsh
!define /IfNDef ERROR_INSTALL_REJECTED 1654

Function .onInit
${If} ${IsServerOS}
    ${If} ${AtLeastWin2003}
    ${AndIf} ${AtMostWin2012R2}
        MessageBox mb_IconStop|mb_OK "Not allowed to run on this version of Windows for some reason!" /SD IDOK
        SetErrorLevel ${ERROR_INSTALL_REJECTED}
        Quit
    ${EndIf}
${EndIf}
FunctionEnd

请记住,这不会阻止 NT4 和 2000 的服务器版本,也不会阻止 Server 2016。您只需要 ${IsServerOS} 检查是否要阻止所有服务器版本。