Thursday, October 30, 2008

Handling Windows Operating System Version Mess

Operating System (OS) like any other software should have a version. So do new OSes from Microsoft.

Sometimes OS version is crucial for the installation software development process. Some products can work on XP and Vista, but cannot work on Windows Server 2003. MSI (Microsoft Installer) has special properties called VersionNT and WindowsBuild to ensure OS version.

Quite logically, eh?

Official documentation gives a reference table with OS versions and build numbers.

Using information from table we can define following WiX condition:

<Condition Message='This software requires the Windows Server
2003 to operate correctly'><![CDATA[VersionNT = "502"]]>
At the bottom of this table we can see strange thing: Vista and Windows Server 2008 have the same VersionNT and WindowsBuild numbers.

Windows Vista6006000Not applicable
Windows Vista Service Pack 1 (SP1)60060011
Windows Server 20086006001Not applicable

So, at this time to determine whether your installer runs on Windows Server 2008 you have to rely on ServicePackLevel property. It is bad, very bad - because when Microsoft will release service pack for the Server 2008 your WIX condition will not be telling truth...

Nontheless, here's how to include Windows Server 2008 launch condition into WIX script:
<Condition Message='This software requires the Windows Server
2003 or 2008 to operate correctly'><![CDATA[Installed OR (VersionNT = 502
OR VersionNT = "600" AND MsiNTProductType > 1)]]>

Update: In the launch condition above property MsiNTProductType was used to differentiate server from workstation