HOW TO: Detect if the Visual C++ 2010 redistributable package is installed with WiX

As noted by Aaron Stebner, there is now a registry key you can search for to detect if the Visual C++ 2010 redistributable package is installed a machine, when installing your application.

There are 3 different (but very similar) registry keys for each of the 3 platform packages. Each key has a DWORD value called “Installed” with a value of 1.

  • HKLMSOFTWAREMicrosoftVisualStudio10.0VCVCRedistx86
  • HKLMSOFTWAREMicrosoftVisualStudio10.0VCVCRedistx64
  • HKLMSOFTWAREMicrosoftVisualStudio10.0VCVCRedistia64

Here’s an example of using this in WiX, detecting the presence of the x86 version of the redistributable:

<?xml version="1.0" encoding="utf-8"?>
    <Include>
        <!-- Visual C++ 2010 x86 -->
        <Property Id="HASVCPP2010">
        <RegistrySearch Id="HasVCPP2010Search" Root="HKLM" Key="SOFTWAREMicrosoftVisualStudio10.0VCVCRedistx86" Name="Installed" Type="raw" />
    </Property>    
    <Condition Message="This application requires Microsoft Visual C++ 2010 Redistributable Package (x86).">Installed OR (HASVCPP2010)</Condition>
</Include>

When someone runs your installer and they don’t have this package installed, they will get something like this message box when the installer initializes:

image

It’s a good idea to have a setup bootstrapper that automatically installs this package if it’s missing, but this WiX snippet is a good safe-guard for if someone directly runs your MSI.

Reference: http://blogs.msdn.com/b/astebner/archive/2010/05/05/10008146.aspx

One thought on “HOW TO: Detect if the Visual C++ 2010 redistributable package is installed with WiX

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>