Recently, I noticed this post on the Big Screen Blog where Niall Ginsbourg talks about some changes he made to the installers for his Big Screen applications for Windows Vista Media Center. He didn’t go into much detail about what he changed, so I want to explain the OS version detection that happens in the WiX v3.0-based installer files included with the Windows Media Center application project templates that ship in the Windows Media Center SDK v5.3 and that I have previously posted on my blog (for example, here and here). I will also outline the types of changes you may want to make in the OS version conditions in your Windows Media Center application installers depending on what scenarios you plan to support in the future.
For the WiX syntax quoted in this blog post, I will refer to the WiX v3.0 setup files that are created by the Visual Studio project templates that ship in the Windows Media Center SDK. You can find these setup files in the Setup sub-folder after creating an instance of one of the Windows Media Center project templates after installing Visual Studio and the Windows Media Center SDK v5.3.
Description of the OS install block in existing Media Center application setup samples
The WiX source file in the Windows Media Center project templates (named Setup.wxs) includes a custom action to block installation if the user attempts to run the MSI on an unsupported OS. The custom action is defined by the following WiX element:
<CustomAction Id=”CA_ErrWrongWindowsVersion” Error=”!(loc.LaunchCondition_WrongOSVersion)” />
Later on in Setup.wxs, the conditions are defined that control when this custom action will be run. The following WiX element is included in both the InstallExecuteSequence table and the InstallUiSequence table in order to make sure that the custom action will run if the MSI is installed in full UI mode or in silent mode:
<Custom Action=”CA_ErrWrongWindowsVersion” Before=”CostInitialize”><![CDATA[(NOT VersionNT = 600 OR NOT MCEINSTALLVERSION = “5.0” OR NOT REGISTERMCEAPP) AND NOT Installed]]></Custom>
There are 4 specific conditions that are checked for this custom action:
- NOT VersionNT = 600 – This checks the built-in Windows Installer property named VersionNT to make sure it is equal to 600, and will cause setup to block if it is not. This is primarily designed to prevent the MSI from installing on older versions of Windows such as Windows XP Media Center Edition (which will have VersionNT = 501), but will also end up preventing installation on future versions of Windows that have the VersionNT value set to something higher than 600 as well.
- NOT MCEINSTALLVERSION = “5.0” – This queries the Ident registry value located at HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Media Center and will cause setup to block if the value does not exist or is not equal to 5.0. This is primarily designed to prevent the MSI from installing on versions of Windows that do not include Windows Media Center features or from installing on systems that have older versions of Media Center (see the chart of Ident values here for more information). However, it will also end up preventing installation on systems if they have future versions of Windows Media Center that have the Ident value set to something higher than 5.0 as well.
- NOT REGISTERMCEAPP – this condition checks to make sure that the file %windir%\eHome\RegisterMceApp.exe exists on the system and has a version number at least 18.104.22.168. This will make sure that at least the Windows Vista version of RegisterMceApp.exe is on the system because it is needed during setup to register the application for use in Windows Media Center.
- NOT Installed – this condition is a standard Windows Installer condition that is typically added to blocking custom actions such as this one. It detects whether or not the current product is already installed, and is intended to prevent the user from being blocked when trying to uninstall the product.
Of the conditions listed above, the VersionNT condition (item 1) and the MCEINSTALLVERSION condition (item 2) are not future-proof. In other words, they will end up causing setup to block on future versions of Windows and Windows Media Center if they end up being configured to use higher values for the VersionNT property and/or the Ident registry value.
When we shipped these example installers in the Media Center SDK, we made a conscious decision to bind the installers to a specific, known version of Windows and Windows Media Center. This is because the known version is the only one that can currently be tested and assured of working correctly with Media Center application code developed using the SDK.
Making the install conditions less restrictive
In your scenario (and in the scenario Niall described in his blog post), you may find these conditions too restrictive and may want to update your Media Center application installer so that you do not necessarily have to release new versions of your installers if new versions of Windows and/or Windows Media Center ship with higher values for the VersionNT property and/or the Ident registry value in the future.
If you would like to loosen the restrictions in your installer, I suggest changing the custom action condition to the following:
<Custom Action=”CA_ErrWrongWindowsVersion” Before=”CostInitialize”><![CDATA[(NOT VersionNT >= 600 OR NOT MCEINSTALLVERSION OR NOT REGISTERMCEAPP) AND NOT Installed]]></Custom>
This condition contains the following changes when compared to the original Setup.wxs file that is created by the project templates in the Windows Media Center SDK:
- NOT VersionNT >= 600 – This condition will cause the MSI to only block on any version of Windows prior to Vista. It will no longer block on any potential future versions of Windows with a VersionNT value greater than 600.
- NOT MCEINSTALLVERSION – This condition will cause the MSI to only block if the Ident registry value does not exist, but will not check the exact Ident version value. It will no longer block on any potential future version of Windows Media Center with an Ident value not equal to 5.0. It could also theoretically run on an older version of Windows Media Center, but you should be protected by the VersionNT check in that case to avoid the MSI running on Windows XP Media Center Edition for example. I chose not to put a greater than or equal check here because the Ident value is a REG_SZ data type in the registry, and greater than or equal checks on strings tend to not always be accurate (for example “10.0” is less than “2.0” when doing string comparisons).
Note that you must make sure to change this condition in both the InstallExecuteSequence table and the InstallUiSequence table in your WXS file or else you will see different install blocking behavior in full UI mode versus silent mode.
A real-world example – PowerPlaylist
You can take a look at the WiX source code for the PowerPlaylist application on Codeplex for an example of less restrictive installation conditions. The installer for PowerPlaylist was initially created from a Windows Media Center project template in the SDK, and it was later modified to contain less restrictive OS installation conditions. PowerPlaylist is used within the Media Center team at Microsoft as an application compatibility test case, so it had to be modified to allow installation on any possible version of Windows Media Center starting with Windows Vista. There are trade-offs related to application compatibilty that you have to make if you decide to make the OS installation conditions in your Media Center application installer less restrictive though – see the note at the end of this blog post for more details.
Note that unlike the recommendation above, the installer for PowerPlaylist does not check for the Ident registry value at all (you will not see any reference to the MCEINSTALLVERSION property in that installer). This option will also work, but I recommend checking that the Ident value exists is an extra safeguard to make sure that the system really does contain Windows Media Center. A system should not be able to contain Windows Media Center functionality without the Ident registry value also being present.
A word of caution about less restrictive installation conditions
If you decide to update the installer for your Media Center application to include less restrictive OS install conditions, please note that this will allow your application to install on any possible future version of Windows and/or Windows Media Center. Since these future versions do not yet exist, it is impossible to know whether or not your application will continue to be compatible with them. Microsoft generally makes a best effort to maintain application compatibility as it releases new versions of Windows, but compatibility cannot be guaranteed. It is strongly advised that you perform compatibility testing for your application as new versions of Windows are released in order to be sure that things still work as expected within your application. By loosening OS install conditions, you are essentially putting some of the compatibility testing burden onto users of your application, which can be frustrating for them.
I realize that most Media Center application developers are not WiX or Windows Installer experts, so the above information might be confusing. Please don’t hesitate to leave a comment on this blog post or contact me if you have more detailed questions about the scenarios described here or would like an opinion about installation behavior that you are considering for your application.