0

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

Below are the unsupported operating systems. In those when installing the software i should show the popup message.

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

I am facing difficulty to implement this. Could any one please guide me on this?

David
  • 9
  • 5

2 Answers2

0

You can use WinVer.nsh to detect Windows versions

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

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

If you need to be more specific, you can combine this with at AtLeastWin* / AtMostWin*, where * is the version you're targeting (e.g. AtLeastWin2003 / AtLeastWin2012R2)

idleberg
  • 12,634
  • 7
  • 43
  • 70
  • Thank you for the solution. While installing, in .OnInit function can I use like as shown below and Quit if it is the windows server operating system? !include "WinVer" Function .onInit ${If} ${IsServerOS} MessageBox MB_OK|MB_ICONQUESTION "You are attempting to install software that is not intended for this version of windows OS" Quit ${EndIf} FunctionEnd – David Apr 16 '19 at 14:39
0

Use WinVer.nsh to detect Windows versions:

!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

Keep in mind that this does not block the server versions of NT4 and 2000 nor Server 2016. You only need the ${IsServerOS} check if you want to block all server versions.

Anders
  • 97,548
  • 12
  • 110
  • 164