Checking for the Visual Studio runtime libraries

Applications developed with Visual Studio 2005, 2008 and 2010 can make use of certain runtime libraries like the C/C++ runtimes, ATL, MFC and OpenMP.

Visual Studio 2005 & 2008 runtimes are shipped as Windows Side-by-Side assemblies. Determining whether these are installed isn’t as straightforward as checking for file existence, as outlined in this post. I promised to put those techniques to use, which I’m doing here, along with a checker for the non-side-by-side 2010 runtimes.

To help understand the install state of the Visual Studio 2005/2008/2010 runtimes, I’ve written the creatively-named "checkruntimes.exe", which you can find in the zip file attached at the bottom of this post.

Usage:
 > checkruntimes.exe –help

Installation checker for Visual Studio runtime libraries
By default checks for versions 8, 9 and 10 of the runtime libraries on
all architectures, both debug & release

Usage:

  checkruntimes.exe [-quiet] [-help] [-8] [-9] [-10] [-debug] [-retail]
                [-x86] [-x64] [-ia64] [-crt] [-atl] [-openmp] [-mfc]

The command-line switches -8 -9 ... -x86 -mfc are restrictions. That is to say,
by default everything is searched, but if specified only those specific
libraries will be searched for.

The return value of the program is the number of libraries found.
If you pass the -quiet switch, no output is generated, so you can use this
program from a script to validate installation state of runtimes.

Examples:

  checkruntimes.exe -9 -retail -x86 -crt
  Check for the Visual C++ v9 (VS 2008) retail 32-bit runtime library.

  checkruntimes.exe -10 -x64
  Check for all Visual Studio version 10 (VS 2010) x64 runtime libraries.

  checkruntimes.exe -8 -ia64 -debug -quiet
  Check for all Visual Studio v8 (VS 2005) debug Itanium-architecture libraries,
  but don't display any output, only return the number found.
Samples:
 > checkruntimes.exe -x86 -crt -8 -10

When called with no arguments, it lists runtimes it can find – calling checkruntimes.exe with no arguments is equivalent to calling:

 > checkruntimes.exe -8 -9 -10 -debug -retail -x86 -x64 -ia64 -crt -atl -openmp -mfc

Of note, the return code is the number of runtimes found of the machine. For example, suppose you were checking for the 32-bit release of the VS2008 CRT & ATL. From a script you could invoke:

 @echo off
checkruntimes -crt -atl -9 -retail -x86 -quiet
echo Found %ERRORLEVEL% libraries
if %ERRORLEVEL% NEQ 2 goto :LibrariesNotFound
echo Success!
goto :EOF
:LibrariesNotFound
echo Some of x86 crt and atl v9 retail not found
Notes:

Visual Studio 2005 is referred to by the version number 8, VS 2008 likewise by the version number 9 and VS2010 by the version number 10.

Note also that while this program can check for their presence, the debug runtimes are not redistributable. You can find more information about those here: https://msdn.microsoft.com/en-us/library/aa985618.aspx

For the Visual Studio 2005 & 2008 runtimes, as they are side-by-side assemblies, there can be multiple versions of each assembly installed. This utility only displays the highest-version assembly installed, as dependencies on lower build/revision numbered assemblies can be satisfied by higher-versioned ones.

What about Visual Studio .NET 2002 and Visual Studio .NET 2003?

While on a development machine these redistributables may be placed System32 by the development environment,  they are not meant to be centrally installed on client machines. Instead, they must be included into each application’s local directory for private use by that application. For  this reason, there’s nothing for this tool to check – the  redistributables should never be centrally installed. For more information on redistribution policies for these versions of Visual Studio, please see here: https://support.microsoft.com/kb/326922.

checkruntimes.zip