Mailbag: How to detect the presence of the VC 8.0 runtime redistributable package


I am building an installer that will include the Visual C++ (VC) 8.0 runtime files redistributable package (vcredist_x86.exevcredist_x64.exe and/or vcredist_ia64.exe) as a prerequisite.  How can I detect whether or not this package is already installed on the user's system so that my installer can skip installing it when appropriate?


There was not a specific detection mechanism designed and built into VC 8.0 runtime files redistributable setup packages.  The setup bootstrapper that ships with Visual Studio 2005 uses the following algorithm to check for the existence of these packages:

  1. Call the MsiQueryProductState API
  2. Pass in the product code for the package that you want to detect based on the list below  
  3. Check the return value of this API.  If it is anything other than INSTALLSTATE_DEFAULT, the package is not yet installed

Visual C++ 2005 runtime files

Visual C++ 2005 SP1 runtime files

Visual C++ 2005 SP1 ATL Security Update runtime files

However, this algorithm is somewhat incomplete.  It does not cover cases where a user has installed some other application on the system that includes the VC 8.0 runtime redistributable merge modules (MSMs) as part of its MSI package.  It also does not cover the case of Windows Vista, where the VC 8.0 runtime files are installed as part of the OS.  (Note - versions of Windows newer than Windows Vista do not treat the VC++ runtime files as system files anymore.  See this knowledge base article for more information.)

The safest way for a setup to manage detection for the VC 8.0 runtime redistributable package is to use an algorithm similar to the one listed above to check for the MSI product code and then install if it is not yet installed.  This may lead to a few cases where the setup will install it when it doesn't technically need to, but that is better than any scenarios where it could might end up not installing it when the VC runtime files are not yet present.  In addition, using this approach will add a reference count to the VC runtime files to prevent scenarios where uninstalling some other application that includes the VC runtime MSMs causes the VC runtime files to be removed from the system.

One important note - the VC runtime redistributable packages require that the system has at least Windows Installer 3.0 (and ideally Windows Installer 3.1 because any future hotfixes produced for this package will require Windows Installer 3.1).  If your setup is going to install the VC runtime redist package, it should also check for the presence of Windows Installer 3.x and install it as well if it is not yet installed on the system.

Other options for installing the VC 8.0 runtime files

I also want to point out that there are other options for applications that depend on the VC 8.0 runtime files besides redistributing the vcredist_x86 or vcredist_x64 MSI packages. 

  • Include the VC runtime MSMs in your MSI package directly - this can cause issues like the ones I described in this previous blog post, but in some cases this is the easiest solution
  • Statically link to the VC runtimes when building your application - this increases the size of your binaries but eliminates the need to validate that these runtime files are present on users' systems at setup time for your application
  • Install the VC runtimes to a local folder for use only with your application - this complicates the installation logic in your MSI and causes hotfixes to not apply for your the version of these runtime files included with your application on Windows 2000

These options have various pros and cons, and the choice you make depends on your applications and the scenarios you want to support.  There is additional discussions of some of the trade-offs on the MSDN Forums (for example, this post and this post).  I encourage you to read some of these posts and others that are included as links within them before making your setup packaging decision for the VC 8.0 runtime files.

<update date="1/24/2006"> Added information about the IA64 version of the VC redist package. </update>

<update date="11/19/2009"> Added information about VC++ 2005 SP1 and VC++ 2005 SP1 ATL Security Update packages. </update>

<update date="2/11/2015"> Added a link to a knowledge base article to help clarify that post-Vista versions of Windows do not include VC++ runtime files as OS components. </update>


Comments (14)
  1. Christian Häfner says:

    Hi Aaron,

    I had the same problem to detect if the VC8 runtime is already installed.

    When I analyzed the wrapped msi from vcredist_x86.exe with Orca I found a registry key HKLMSOFTWAREMicrosoftDevDivVCServicing8.0RED1033Install. I use this key to determine if the VC8 runtime is on the box.

    Is this way OK or is it unrecommended?



  2. Hi Christian – Yes, I see that registry value in the MSI for the vcredist_x86.exe package.  It should also be safe to use that key/value to determine whether or not the VC 8.0 runtime redist package is installed on a user’s system.

    This approach has the same caveat as the product code-based algorithm that I described in the main post – there may be cases where this registry key doesn’t exist, but the user already has the VC runtimes on their system.

  3. I posted an item last week that described how to detect the presence of the Visual C++ 8.0 runtime files

  4. ttanner says:

    Hi Aaron,

    A small thing about installing the vc runtime to a local directory (aka applocal install).

    The vc_redist installs to the sxs cache and has to be installed per-machine.

    The load order for side-by-side dlls actually loads the sxs dlls in preference to the applocal dlls. So when you install the original vc 2005 dlls in your directory (applocal) and install the vc2005sp1 redist (sxs cache), your app will load the vc2005sp1 dlls.


  5. Question: I have built an application in Visual Studio 2005 that depends on the VC 8.0 runtime files

  6. I have previously posted a few items about deploying the Visual C++ 8.0 runtime redistributable packages

  7. I previously wrote a blog post about updated versions of the Visual C++ 8.0 runtime files that shipped

  8. Question: I saw a couple of previous blog posts that you wrote about how to detect the presence of the

  9. Question: You previously posted a list of command line switches to perform silent and unattended installations

  10. Joost van Zoest says:

    For the Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update (x86) the Product Code is:


  11. TLama says:

    According to this article…/en-us (and report from this comment…/11172939), the VC runtime is no longer considered a system file, and your note "It also does not cover the case of Windows Vista, where the VC 8.0 runtime files are installed as part of the OS." might be misleading for those expecting the runtime on any newer Windows versions.

  12. Hi TLama – Thanks for posting this clarification.  I wrote this blog post back in 2007 before the changes that you reference about the VC runtime files no longer being considered system files.  I'll go back and update the text of the blog post as well to avoid potential confusion on post-Vista versions of Windows.

    1. Murali says:

      Hello Aaron,

      We would like to install the Microsoft Visual C++ 2005 Redistributable Package 8.0.50727.762 in a machine via Command script. After reading your blog I am trying to execute the following to install the vc++ before we install our files.

      ExecWait vcredist_x86.exe /q:a /c:”VCREDI~3.EXE /q:a /c:””msiexec /i vcredist.msi /qn”” ”

      But I would like to check existense of the VC++ before I install via command line. How to check it?

      I tried with the below C# code in the machine that already installed this package. But no luck. I am getting -1 always

      static void Main(string[] args)
      var installed = CheckForVC2005SP1Redist();
      Console.WriteLine(“VC++ SP1 Exists= ” + installed);

      static bool CheckForVC2005SP1Redist()
      bool install = false;

      var state= MsiQueryProductState(“{7299052B-02A4-4627-81F2-1818DA5D550D}”);
      if (state == 3 || state == 5)
      return true;

      return install;

      private static extern int MsiQueryProductState(string product);

      Is there a way to detect? Or I am missing any?

      1. Hi Murali – This sample code should allow you to detect whether or not that one product code is installed on a PC. Can you double-check that this product code is truly installed on the PC that you’re running the test code on? Also, what exact state value is being returned when you call MsiQueryProductState in your scenario?

Comments are closed.

Skip to main content