繁体   English   中英

安装使用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}检查。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM