Wix Toolset CustomAction for determining if the OS is windows 7/xp home edition or starter edition and display message for not

StackOverflow https://stackoverflow.com//questions/23056217

  •  23-12-2019
  •  | 
  •  

Question

I am new to Wix Toolset installation. I am using Wix 3.7 and Visual Studio 2010 SP1.

I was going through a tutorial which uses BootStrapper in which there is a conditional Message in Product.Wxs file for checking .NET framework 4.0 is installed there is a PropertyRef Id variable and Condition Message

<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="This application requires .NET Framework 4.0. Please install the .NET Framework then run  
   this installer again.">
  <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>

How can one similarly check for Condition for Windows XP Starter/Home and Windows 7 Starter/Home/Home Premium editions and show conditional message that the installation does not support the OS listed and require Professional Editions.

I have gone through the links on Wixtoolset website, but it didn't help:

Checking Windows Versions http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/block_install_on_os.html

http://msdn.microsoft.com/library/aa370556.aspx

I have also tried to place the condition in the bootstrapper's Bundle.wxs file as:

<Bundle Name="!(loc.ProductName)" Compressed="yes" Version="1.2.6.0"  
SplashScreenSourceFile="Resources\SplashScreen.bmp" IconSourceFile="Resources\IXMWeb.ico"  Manufacturer="! 
(loc.ManufacturerName)" UpgradeCode="FED377E5-8762-48C4-B123-8D4AD89B0222" Condition="((VersionNT >= v5.1) AND 
(ServicePackLevel >= 3) AND NOT(NTSuitePersonal)) OR ((VersionNT >= v5.2) AND (ServicePackLevel >= 2)) OR 
(VersionNT >= v6.0 AND NOT(NTSuitePersonal))">

I have gone through the post that I need to use NTSuitePersonal instead of MsiNTSuitePersonal for checking if the edition is Home edition which is being installed.

Please let me know where i am not correct in the above condition used.

Was it helpful?

Solution

For checking the Windows version (i.e. Windows XP, Vista, 7, 8, ...) you can use the VersionNT-property as described in the links provided by you. For checking the edition (i.e. Home, Premium, Professional, ...), according to this SO-question, you can use the values below the registry hive HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion.
In combination with WiX you could do a registry search that sets a property and then use this property in your condition (I could verify the exact registry key only on Windows 7 Professional where it is names EditionID):

...

<Property Id="WINDOWSEDITION" Secure="yes">
    <RegistrySearch Id="WindowsEditionReg" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion" Name="EditionID" Type="raw" />
</Property>

...

See also How to: Read a registry entry during installation.

Edit: Using the properties named in your link Operating System Property Values and the How To: Read a Registry Entry During Installation and the How To: Block Installation Based on OS Version, an example of checking if the user has Windows 7 Professional with Service Pack 1 installed and deny the installation on everything else would then be (put it inside the Product-tag):

<Condition Message="This application can only be installed on Windows 7 Professional with Service Pack 1.">
    <![CDATA[Installed OR (VersionNT = 601 AND WindowsBuild > 7100 AND WINDOWSEDITION ~= "Professional")]]>
</Condition>

The Installed-property on the beginning of the condition ensures that the condition is only validated if the product isn't already installed. Within the parenthesis we then find the other conditional elements. We ensure that we run on Windows 7 (VersionNT = 601 AND WindowsBuild > 7100) and that the edition is correct (WINDOWSEDITION ~= "Professional"). Note that the ~= checks the string case insensitive.
For the syntax of the conditional statements you can take a look here. You can of course combine any additional conditions using OR, AND and grouping them with parentheses where appropriate. In a real world scenario you would most probably have another condition, like Windows 7 and higher versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top