1

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.

user3041212
  • 76
  • 1
  • 8

1 Answers1

2

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.

Community
  • 1
  • 1
taffit
  • 1,979
  • 22
  • 23
  • Hi! Thanks a lot. how can i use this property id in my condition? – user3041212 Apr 15 '14 at 06:46
  • I've edited the answer above with an example and additional links. – taffit Apr 15 '14 at 07:51
  • Thanks a ton man! This worked for me. Thanks once again. Just one more thing, can you please suggest some good tutorials for wix and what should be the pre-requisite to learn wix. From what I can make uptill now is that one should have a good understanding of the following: 1. Windows Installer 2. XML 3. Wix Variables 4. WPF (In case of Bootstrapper) 5. Registry Structure of windows. Is there anything else one should know. Please add some links too. Once again, thank you so much. – user3041212 Apr 15 '14 at 09:35
  • We are using ~= condition for checking Professional Edition. How can I check for case insensitive != for "Personal" Edition? I mean, I am using WINDOWSEDITION <> "Personal" as per the conditional statements table. But this condition evaluates to true. WINDOWSEDITION != "Personal" WINDOWSEDITION !~= "Personal" WINDOWSEDITION ~!= "Personal" It is giving me error. – user3041212 Apr 15 '14 at 10:17
  • Just use the negation: `NOT (WINDOWSEDITION ~= "Personal")`. – taffit Apr 15 '14 at 10:28
  • tried with that too. I ended up using all the Suite names given in the table in this link. http://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/exinit/productsuite.htm – user3041212 Apr 15 '14 at 10:40
  • Regarding the links for learning WiX: I personally think that if you are learning WiX (mostly by doing) the rest comes automatically, as you have to check for different solutions for the problems you encounter during development, e.g. read about WI tables, condition, etc. Helpful: [WiX tricks and tips](http://stackoverflow.com/questions/471424/wix-tricks-and-tips) and the [tutorial from tramontana](http://wix.tramontana.co.hu/). Also the WiX help file with its different How tos is my daily read ;-). Never worked with the WiX Bootstrapper though (until now). – taffit Apr 15 '14 at 12:30
  • 1
    You should try the MsiNTSuitePersonal property to find out if it's a Home edition. – PhilDW Apr 16 '14 at 16:36
  • Good answer @PhilDW ! I wasn't aware of this property, thank you. – taffit Apr 17 '14 at 09:15
  • @taffit : I tried using MsiNTSuitePersoanl property. But it didn't work for me. Rather a much better approach was to use the custom action for OS. More details: http://wixtoolset.org/documentation/manual/v3/customactions/osinfo.html – user3041212 Apr 29 '14 at 12:08
  • The values of `VersionNT` are [documented here](https://learn.microsoft.com/en-us/windows/win32/msi/operating-system-property-values) -- these appear to stop at 602 i.e. Windows 8 or Windows Server 2012. So how to distinguish e.g. Windows Server 2016 or Windows Server 2019? – ChrisW Nov 16 '21 at 16:03
  • According to [this entry](https://learn.microsoft.com/en-us/troubleshoot/windows-client/application-management/versionnt-value-for-windows-10-server), in order to maintain compatibility, the mentioned versions are `603` for Win 10, Server 2016 and Server 2019. – taffit Nov 18 '21 at 10:41