How to Create Launch Conditions in WiX Installer

This article shows useful installation launch conditions in WiX Installer. Installation conditions are added to Wix to filter out if the application package can be installed in the environment. If conditions are not met, the installation will not continue and be aborted.

Condition: VersionNT64

VersionNT64 returns Windows Version if PC is based on 64bit Operating System.

VersionNT64 Property can be used for launching conditions. This example prevents an installer from installing on a Windows 32bit OS environment.

   <Condition Message="This installer does not support 32bit Windows OS.">
      <![CDATA[Installed OR VersionNT64]]>
   </Condition>

Condition: WindowsBuild

WindowsBuild Property retrieves OS Build Number.

If Windows 10 OS version 1909 or later versions is a prerequisite, multiple conditions can be set: OS is Workstation type AND Build Version is larger than 18363.

 <Condition Message="This Application supports Windows 10 Version 1909 or later versions">       
        <![CDATA[Installed OR ( MsiNTProductType = 1 AND WindowsBuild >= 18363) ]]> 
 </Condition>

Condition: MsiNTProductType

MsiNTProductType gets Windows product types: 1 for Workstations, 2 for Domain Controllers, and 3 for Servers.

   <Condition Message="This installer does not support Server Windows OS.">
      <![CDATA[Installed OR MsiNTProductType=1 ]]>
   </Condition>

Condition: Privileged

Privileged checks if elevated privilege is required.

   <Condition Message="You are supposed to have administrator privilege. ">
        Privileged 
    </Condition>

Condition: .NET version

WixNetExtension is to be added to a reference to use NETFRAMEWORK45 Property. The Property can also be used to check .NET 4.5 product family such as for .NET 4.7.2 or .NET 4.8.

.NET version can be detected upon Microsoft .NET framework version detection guideline. As an example, .NET 4.7.2 was starting from 461808.

    <PropertyRef Id="NETFRAMEWORK45"/>

    <Condition Message="This application requires .NET Framework 4.7.2">
		<![CDATA[Installed OR NETFRAMEWORK45 >= "#461808"]]> 
    </Condition>

Run:

More articles you may be interested in:

How to update XML File during Install in WIX

How to add a Custom Dialog in Wix Installer

How to Create Wix Project in Visual Studio 2019

Leave a Comment