如何限制WIX安装程序仅在Windows Server 2016及以上版本运行?
Hey there, let's break down why your current condition isn't blocking Windows Server 2012 R2 and get it sorted out.
The Root Problem
Your assumption about the VersionNT value for Windows Server 2016 is off a bit. Here's the real deal:
- Windows Server 2012 R2 (and Windows 8.1) uses VersionNT = 603
- Windows Server 2016 (and Windows 10) uses VersionNT = 1000
So your original condition VersionNT >= 603 is letting Server 2012 R2 slip through because it meets the 603 threshold.
Solution 1: Target Server 2016+ (Including Client OS like Windows 10)
If you just need to block anything older than Server 2016 (and don't mind allowing Windows 10/11 clients), update your condition to check for VersionNT 1000 or higher:
<Condition Message="!(loc.RequireServer2016)"><![CDATA[INSTALLED OR (VersionNT >= 1000)]]></Condition>
Solution 2: Restrict to ONLY Server 2016+ (Block Client OS)
If you want to strictly limit installation to server operating systems (no Windows 10/11 clients), combine VersionNT with the ProductType property, which distinguishes client vs server systems:
ProductType = 1: Client OS (Windows 10/11, Windows 8.1, etc.)ProductType = 2: Domain ControllerProductType = 3: Standalone Server
Your condition should look like this:
<Condition Message="!(loc.RequireServer2016)"> <![CDATA[INSTALLED OR ((VersionNT >= 1000) AND (ProductType >= 2))]]> </Condition>
The ProductType >= 2 ensures we only allow server environments (both domain controllers and standalone servers) that meet the VersionNT requirement.
Quick Verification
To confirm the VersionNT values for different Windows versions, remember that server OS versions align with their client counterparts:
- Server 2012 → Windows 8 (VersionNT 602)
- Server 2012 R2 → Windows 8.1 (VersionNT 603)
- Server 2016 → Windows 10 1607 (VersionNT 1000)
- Server 2019 → Windows 10 1809 (VersionNT 1000)
- Server 2022 → Windows 11 21H2 (VersionNT 1000)
This should lock down your installer to only run on Windows Server 2016 and newer.
内容的提问来源于stack exchange,提问作者Josh

