Detect if Visual C++ Redistributable for Visual Studio 2012 is installed - visual-c++

How to detect if Visual C++ Redistributable for Visual Studio 2012 is installed?
I tried Google it and nobody has asked this question, surprise!

It depends on what version you are using. These two 2012 keys have worked well for me with their corresponding versions to download for Update 4. Please be aware that some of these reg locations may be OS-dependent. I collected this info from a Windows 10 x64 box. I'm just going to go ahead and dump all of these redist versions and the reg keys I search for to detect installation.:
Visual C++ 2005
Microsoft Visual C++ 2005 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182
Configuration: x64
Version: 6.0.2900.2180
Direct Download URL: https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x64.EXE
Microsoft Visual C++ 2005 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a
Configuration: x86
Version: 6.0.2900.2180
Direct Download URL: https://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.EXE
Visual C++ 2008
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161 (SP1)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D
Configuration: x64
Version: 9.0.30729.6161 (Actual $Version data in registry: 0x9007809 [DWORD])
Direct Download URL: https://download.microsoft.com/download/2/d/6/2d61c766-107b-409d-8fba-c39e61ca08e8/vcredist_x64.exe
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161 (SP1)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0
Configuration: x86
Version: 9.0.30729.6161 (Actual $Version data in registry: 0x9007809 [DWORD])
Direct Download URL: https://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe
Visual C++ 2010
Microsoft Visual C++ 2010 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F
Configuration: x64
Version: 10.0.40219.325
Direct Download URL: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe
Microsoft Visual C++ 2010 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A
Configuration: x86
Version: 10.0.40219.325
Direct Download URL: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
Visual C++ 2012
Microsoft Visual C++ 2012 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}
Configuration: x64
Version: 11.0.61030.0
Direct Download URL: https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe
Microsoft Visual C++ 2012 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}
Configuration: x86
Version: 11.0.61030.0
Direct Download URL: https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe
version caveat: Per user Wai Ha Lee's findings, "...the binaries that come with VC++ 2012 update 4 (11.0.61030.0) have version 11.0.60610.1 for the ATL and MFC binaries, and 11.0.51106.1 for everything else, e.g. msvcp110.dll and msvcr110.dll..."
Additional Caveat -- 2012 Update 4: Per user Krptodr
VC++ 2012 Update 4 (x86) shows under GUID {95716cce-fc71-413f-8ad5-56c2892d4b3a}
VC++ 2012 Update 4 (x64) shows under GUID {a1909659-0a08-4554-8af1-2175904903a1}
^^ The GUID's provided are for the installer package. However, these branch off into two other GUID's respective of their arch type. For further information please see the following source How to check if the Microsoft Visual C++ Runtime is installed
Visual C++ 2013
Microsoft Visual C++ 2013 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{042d26ef-3dbe-4c25-95d3-4c1b11b235a7}
Configuration: x64
Version: 12.0.40664.0
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/10912041/cee5d6bca2ddbcd039da727bf4acb48a/vcredist_x64.exe
Microsoft Visual C++ 2013 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}
Configuration: x86
Version: 12.0.30501.0
Direct Download URL: https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe
Visual C++ 2015
Consider using the 2015-2019 bundle as an alternative
Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.24215
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{d992c12e-cab2-426f-bde3-fb8c53950b0d}
Configuration: x64
Version: 14.0.24215.1
Direct Download URL: https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe
Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24215
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{e2803110-78b3-4664-a479-3611a381656a}
Configuration: x86
Version: 14.0.24215.1
Direct Download URL: https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x86.exe
Visual C++ 2017
Consider using the 2015-2019 bundle as an alternative
Caveat: There's either a new 2017 registry convention being used, or it hasn't been finalized, yet. As I'm guessing the upper-most keys of:
[HKEY_CLASSES_ROOT\Installer\Dependencies\,,amd64,14.0,bundle]
and
[HKEY_CLASSES_ROOT\Installer\Dependencies\,,x86,14.0,bundle]
are subject to change, or at least have different nested GUIDs, I'm going to use list the key that ends with a GUID.
Microsoft Visual C++ 2017 Redistributable (x64) - 14.16.27012
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x64,amd64,14.16,bundle\Dependents\{427ada59-85e7-4bc8-b8d5-ebf59db60423}]
Configuration: x64
Version: 14.16.27012.6
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/9fbed7c7-7012-4cc0-a0a3-a541f51981b5/e7eec15278b4473e26d7e32cef53a34c/vc_redist.x64.exe
Microsoft Visual C++ 2017 Redistributable (x86) - 14.16.27012
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x86,x86,14.16,bundle\Dependents\{67f67547-9693-4937-aa13-56e296bd40f6}]
Configuration: x86
Version: 14.16.27012.6
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/d0b808a8-aa78-4250-8e54-49b8c23f7328/9c5e6532055786367ee61aafb3313c95/vc_redist.x86.exe
Visual C++ 2019 (2015-2019 bundle)
Caveat: There's another new registry convention being used for Visual C++ 2019. There also doesn't appear to be a standalone installer for Visual C++ 2019, only this bundle installer that is Visual C++ 2015 through 2019.
14.21.27702
Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.21.27702
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x64,amd64,14.21,bundle\Dependents\{f4220b74-9edd-4ded-bc8b-0342c1e164d8}]
Configuration: x64
Version: 14.21.27702
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/9e04d214-5a9d-4515-9960-3d71398d98c3/1e1e62ab57bbb4bf5199e8ce88f040be/vc_redist.x64.exe
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.21.27702
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x86,x86,14.21,bundle\Dependents\{49697869-be8e-427d-81a0-c334d1d14950}]
Configuration: x86
Version: 14.21.27702
Direct Download URL: https://download.visualstudio.microsoft.com/download/pr/c8edbb87-c7ec-4500-a461-71e8912d25e9/99ba493d660597490cbb8b3211d2cae4/vc_redist.x86.exe
14.22.27821
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.22.27821
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x86,x86,14.22,bundle\Dependents\{5bfc1380-fd35-4b85-9715-7351535d077e}]
Configuration: x86
Version: 14.22.27821
Direct Download URL:
https://download.visualstudio.microsoft.com/download/pr/0c1cfec3-e028-4996-8bb7-0c751ba41e32/1abed1573f36075bfdfc538a2af00d37/vc_redist.x86.exe
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.22.27821
Registry Key: [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x64,amd64,14.22,bundle\Dependents\{6361b579-2795-4886-b2a8-53d5239b6452}]
Configuration: x64
Version: 14.22.27821
Direct Download URL:
https://download.visualstudio.microsoft.com/download/pr/cc0046d4-e7b4-45a1-bd46-b1c079191224/9c4042a4c2e6d1f661f4c58cf4d129e9/vc_redist.x64.exe
Changelog:
October 26th, 2021 -- Updated to further clarify findings on October 21st.
October 21st, 2021 -- Added additional caveat details for VC++2012 Update 4 (x86) and (x64) GUID's per Krptodr's findings.
August 19th, 2019 -- Added a new version of 2015-2019 bundle version
June 13th, 2019 -- Added a new section for the 2015-2019 bundle version 14.21.27702 and added small notes to the 2015 and 2017 sections about considering the usage of the new bundle as an alternative.
December 14th, 2018 -- Updated MSVC2008 for Service Pack 1's 9.0.30729.6161 update per Jim Wolff's findings
November 27th, 2018 -- Updated info for MSVC2017 v. 14.16
September 12th, 2018 -- Added version caveat to 2012 Update 4 per Wai Ha Lee's findings
August 24th, 2018 -- Updated 2017's version for 14.15.26706, the updated Visual C++ dependencies packaged with VS 2017 15.8.1
May 16th, 2018 -- Updated 2017's version for 14.14.26405.0 as the new C++ 2017 entry
September 8th, 2017 -- Updated 2017's version for 14.11.25325.0 as the new Visual C++ 2017 entry
April 7th, 2017 -- Updated 2017's version of 14.10.25008.0 as the new Visual C++ 2017 entry
October 24th, 2016 -- Updated 2015's version info for 14.0.24215.1
August 18th, 2016 -- Updated 2015's version info for 14.0.24212
May 27th, 2016 -- Updated info for MSVC2015 Update 2

Try
HKLM\SOFTWARE\Microsoft\DevDiv\VC\Servicing\11.0
as a starting point. I will be using this as a check for installing the VC++ 11 (VS 2012) runtime.

You can check for the Installed value to be 1 in this registry location: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes\x86 on 64-bit systems. In code that would result in accessing registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86. Notice the absence of Wow6432Node.
On a 32-bit system the registry is the same without Wow6432Node: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86

There is no installcheck element in the bootstrapper package manifest shipped with Visual C++. Guess Microsoft wants to always install if you set it as a prerequisite.
Of course you can still call MsiQueryProductState to check if the VC redist package is installed via MSI, The package code can be found by running
wmic product get
at command line, or if you are already at wmic:root\cli, run
product where "Caption like '%C++ 2012%'"

The answer to this simple questions is unfortunately not a simple one, but working in 100% of all systems, and even extendable to the numerous .net frameworks.
The complexity comes from the fact that there are (and were) many VC runtimes revisions which could lead to the case that although VC10 runtimes were installed, their build number was not recent enough so your EXE wouldn't start unless you either installed the very exact runtimes you required or one of the newer runtimes which enable this and previous versions for the same major version to run with it (the side-by-side hell).
Also, if you have a 64 bit EXE, you will have to check for both, the 32 AND 64 bit runtimes.
That said, the only reliable way to determine whether the runtimes for your EXE are installed is to attempt to run the EXE - or a another EXE which is built with the same settings as your main EXE and whose only purpose is to do - nothing. Just run (which means the runtimes are installed) or fail to run (when not installed).
I did the following for an installer which required the VC10 32 and 64 bit runtimes installed: The installer attempts to launch all dummy EXEs and if it succeeds, the corresponding runtime is considered to be installed. This also resolves the 32/64 bit scenario.
This, by the way, works also to determine if the proper .net framework is installed, which is very tricky in Windows 8 and 10, as the downloadable built-in .net 3.5 support also supports the .net versions 3.0 and 2.0 - there are no registry entries for these.
(And worse, you cannot even use the standard framework installers here, you must use the built-in support and download it via Windows, or rebuild your app with .net 4, but that's another story).
The C++ dummy EXE can be built using a project with the following code (and another one in a 64 bit configuration if necessary):
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Remember to set the project's properties Use of MFC to Use MFC in a shared DLL.
The executables will be around 4KB in size - a small price to pay for a sure result.
To give your users a nice installation experience, you could do the following (sample code is for NSIS):
Function TryLaunchApplication
Pop $1 ; pathname
nsExec::Exec $1
Pop $0
${If} $0 == "error"
${OrIf} $0 != 0
Push 0
${Else}
Push 1
${EndIf}
FunctionEnd
and call it in a function, e.g. CheckRuntimes
Function CheckRuntimes
; Try to execute VC++ 10 application (32 bit)
Push "Vc10RuntimeCheckerApp.exe"
Call TryLaunchApplication
Pop $Vc10RuntimesFound
; Add 64 bit check if required.
; Remember to try running the 64 bit EXE only on a 64 bit OS,
; which requires further checks.
; Try to execute .net application
Push "DotNetRuntimeCheckerApp.exe"
Call TryLaunchApplication
Pop $DotNetFrameworkFound
FunctionEnd
Then launch the runtime check e.g. when leaving the Welcome page and cache the result, so you don't have to re-check every time the user clicks on the "Back" and "Next" button.
Next, make a read-only section in the install tree and pre-select or unselect it on the a function which is executed before the Components page is shown.
This will make sure that the installation of each missing runtime component is mandatory, and is skipped if it is already present.

Since Visual Studio 2010 and later stopped using WinSxS, it may be enough to just check for %windir%\system32\msvcr110.dll. If you want to verify you have a new enough version, you can check whether the file version is 11.0.50727.1 (VS2012 RTM) or 11.0.51106.1 (VS2012 Update 1).

I came across this question looking for an answer in the context of checking for the Visual C++ redistributable as part of an MSI installer created by WiX.
I didn't like how the GUID's change with version and operating system, so I ended up creating a custom action written in C# to check for the Visual C++ redistributable.
Everything below is specifically for Visual C++ 2015 Redistributable (x64), but it can be easily modified for any version.
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
namespace CustomActions
{
public class DependencyChecks
{
[CustomAction]
public static ActionResult IsVC2015RedistInstalled(Session session)
{
session.Log("Begin Visual C++ 2015 Redistributable installation check.");
var dependenciesKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Classes\\Installer\\Dependencies");
foreach(var subKey in dependenciesKey.GetSubKeyNames())
{
var dependency = dependenciesKey.OpenSubKey(subKey);
var displayName = (string)dependency.GetValue("DisplayName");
if(displayName != null)
{
if (displayName.Contains("Microsoft Visual C++ 2015 Redistributable (x64)"))
{
session.Log("Visual C++ 2015 Redistributable is installed.");
return ActionResult.Success;
}
}
}
session.Log("Visual C++ 2015 Redistributable is not installed.");
session.Message(InstallMessage.Error, new Record(1, "This application requires Visual C++ 2015 Redistributable. Please install, then run this installer again. https://www.microsoft.com/en-us/download/details.aspx?id=53587"));
return ActionResult.Failure;
}
}
}
Then in the wxs file
<Binary Id='VC2015RedistCheck' SourceFile='!(wix.ResourcesDir=resources)\CustomActions.CA.dll'/>
<CustomAction
Id='VC2015RedistCheckAction'
Execute='immediate'
BinaryKey='VC2015RedistCheck'
DllEntry="IsVC2015RedistInstalled"
Return='check'/>
<InstallExecuteSequence>
<Custom Action='VC2015RedistCheckAction' After='InstallInitialize'/>
</InstallExecuteSequence>
Edit
I'm updating this answer with some basic info on creating and using a custom action.
To create the custom action in Visual Studio 2017 with the WiX Toolset Visual Studio 2017 extension installed, I used the project template to create a custom action (C# Custom Action Project for WiX v3).
I checked the generated project and it seemed to already have the changes listed at the beginning of this article: https://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed so I picked that article up at the section Adding Custom Action to the Installer and followed it through with some tweaks.
One other thing that I did was change the version of the .NET framework the project is built against to 3.5.
I didn't find it really useful but you can also see http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html

For me this location worked:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\11.0\RuntimeMinimum\Version
Check what version you have after you installed the package and use that as a condition in your installer. (mine is set to 11.0.50727 after installing VCred).

Just go to Control Panel > Programs and Features, and they all appear listed there.
I'm no expert and this answer is pretty simple compared to what people are answering (checking registry), so I'm not sure if it's the correct answer but it did the trick for me.

if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86","Installed") = 0 Then
if RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86","Installed") = 0 Then

I've succeded doing this with InnoSetup.
I checked the existence of registry key:
HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes
If uninstalled, it does not exist. If installed, it exists.
By the way, it could also be in the Wow6432Node:
HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes

Checking the install state for the product via MsiQueryProductState is pretty much equivalent to checking the registry directly, but you still need the GUID for the ProductCode.
As mentioned elsewhere, one drawback with these approaches is that each update has its own ProductCode!
Thankfully, MSI provides an UpgradeCode which identifies a 'family' of products. You can use orca to open up one of the MSIs to extract this information. For example, the UpgradeCode for VS2015's redistributable is {65E5BD06-6392-3027-8C26-853107D3CF1A}
You can use MsiEnumRelatedProducts to get all Product IDs for that UpgradeCode. In practice, since each redist update replaces the previous one, this will only yield one ProductCode - such as {B5FC62F5-A367-37A5-9FD2-A6E137C0096F} for VS2015 Update 2 x86.
Regardless, you can then check the version via MsiGetProductInfo(productCode, INSTALLPROPERTY_VERSIONSTRING, ...) or similar functions to compare with the version you want, eg to check for an equivalent or later version.
Note that within a C++ application, you can also use _VC_CRT_MAJOR_VERSION, _VC_CRT_MINOR_VERSION, _VC_CRT_BUILD_VERSION if you #include <crtversion.h> -- this way you can determine calculate the CRT version that your binary was built with.

This PowerShell code should do the trick
Get-ItemProperty
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Format-Table –AutoSize

I needed the same thing, and although AFAIK this cannot be done programmatically, it worked for me.
I just went to Start --> Uninstall a program, and scrolled down until I found the VC++ redistributable, which includes a version number. Googling the version number, told me it belongs to VS2012 SP1.

Old question but here is the approach we have used ever since Visual Studio 2005 with success. I just tested it using Visual Studio 2012 Update 4 as well (since we are finally updating our software from 2010 to 2012).
Since the Visual C++ Redistributable packages register their uninstaller with windows (so it shows up in the Control Panel "Programs and Features" list), we simply check for the Display Name of the uninstaller key in the registry.
Here is the relevant NSIS code:
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}\" "DisplayName"
StrCmp $0 "Microsoft Visual C++ 2012 Redistributable (x86) - 11.0.61030" vs2012redistInstalled
DetailPrint "Microsoft Visual C++ 2012 Update 4 Redistributable not found!"
DetailPrint "Downloading from www.mywebsite.com"
; insert applicable download code here
ExecWait '"<downloaded redist exe>" /promptrestart /passive'
vs2012redistInstalled:
Note that since our installer is a 32bit exe, windows handles determining if the registry key is actually in the virtualized Wow6432Node instead of the above location so the above code works on both 64bit and 32bit windows installs without having to check both keys explicitly.
Also note that to update the above code to a different version of the VC++ Redist, simply change the GUID in the registry key path and the display name to whatever you need.
While this may not be the recommended method, It has worked on 10,000+ machines over the past 10 years running every flavor of windows from XP/XP64 Through Windows 10 using redists for 2005, 2010, 2010sp1, and now 2012u4.

I would check the Installed value of
HKLM\SOFTWARE\[WOW6432Node]\Microsoft\Windows\CurrentVersion\Uninstall\{VCRedist_GUID} key
where GUID of VC++ 2012 (x86) is {33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}
WOW6432Node will be present or not depending on the VC++ redist product

What most people miss is the required /reg:32 to check for the key on Windows x64.
See Microsoft Help article on this subject.
Here is a script that demonstrates how to correctly check for Visual C++ Redistributable for Visual Studio 2012 Update 4.
#ECHO OFF
:Author
REM "CREATED BY WAR59312"
REM "FEB 7th 2017"
REM Clear Screen
CLS
TITLE Detect Visual C++ 2012 Redistributables
REM This Batch Script Detects If Visual C++ Redistributable for Visual Studio 2012 Update 4 Is Installed
:DetectWindowsOS
REM Are We Running On x86 Or x64
IF NOT DEFINED PROCESSOR_ARCHITEW6432 (
IF %PROCESSOR_ARCHITECTURE% EQU x86 (
REM Windows Is x86
GoTo Check32Bit
) ELSE (
REM Windows Is x64
SET NeededFor64BitOnly=/reg:32
GoTo Check64Bit
)) ELSE (
REM Windows Is Unknown But Assume x64 To Be Safe
SET NeededFor64BitOnly=/reg:32
GoTo Check64Bit
)
:Check64Bit
REM Checks If Visual C++ 64Bit Redistributable for Visual Studio 2012 Update 4 Is Installed
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x64" /v "Version" %NeededFor64BitOnly% 2>NUL^ | (
FIND "v11.0.61030.00" >NUL
) && (
ECHO.
ECHO 64bit Visual C++ Redistributable for Visual Studio 2012 Update 4 Is Installed
ECHO.
GoTo Check32Bit
) || (
ECHO.
ECHO 64bit Visual C++ Redistributable for Visual Studio 2012 Update 4 Is NOT Installed
ECHO.
GoTo Check32Bit
)
:Check32Bit
REM Checks If Visual C++ 32Bit Redistributable for Visual Studio 2012 Update 4 Is Installed
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86" /v "Version" %NeededFor64BitOnly% 2>NUL^ | (
FIND "v11.0.61030.00" >NUL
) && (
ECHO.
ECHO 32bit Visual C++ Redistributable for Visual Studio 2012 Update 4 Is Installed
) || (
ECHO.
ECHO 32bit Visual C++ Redistributable for Visual Studio 2012 Update 4 Is NOT Installed
)
:END
ECHO.
PAUSE
EXIT

The powershell script solution:
Based on the information in the answer from #kayleeFrye_onDeck
I have created a powershell script that checks and installs the versions the user specifies, i haven't done extensive testing with it, but for my own CI (Continuous Integration) scenario it work perfectly.
The full script and info on github
The approach i used was based on checking the regkeys based on information provided here. The following is the gist of what the script does:
function Test-RegistryValue {
param (
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Path,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]$Value
)
try {
Get-ItemProperty -Path "$($Path+$Value)" -ErrorAction Stop | Out-Null
return $true
}
catch {
return $false
}
}
The checking/downloading/silently installing based on $redistInfo which contains the compiled information from kayleeFrye_onDeck's.
$redistInstalled = Test-RegistryValue -Path $redistInfo.RegPath -Value $redistInfo.RegValue
if($redistInstalled -eq $False) {
Invoke-WebRequest -Uri $redistInfo.DownloadUrl -OutFile $downloadTargetPath
Start-Process -FilePath $downloadTargetPath -ArgumentList "$($redistInfo.SilentInstallArgs)" -Wait -NoNewWindow | Wait-Process
}
The full script and more information can be found on github
Anyone is welcome to contribute, if i have time i will do more extensive testing of the script and keep trying to add new packages as information is added here.

It is hard to get all registry values for VC 2012 so I have written a small function which will go through all dependencies and match on specified version.
public static bool IsVC2012Installed()
{
string dependenciesPath = #"SOFTWARE\Classes\Installer\Dependencies";
using (RegistryKey dependencies = Registry.LocalMachine.OpenSubKey(dependenciesPath))
{
if (dependencies == null) return false;
foreach (string subKeyName in dependencies.GetSubKeyNames().Where(n => !n.ToLower().Contains("dotnet") && !n.ToLower().Contains("microsoft")))
{
using (RegistryKey subDir = Registry.LocalMachine.OpenSubKey(dependenciesPath + "\\" + subKeyName))
{
var value = subDir.GetValue("DisplayName")?.ToString() ?? null;
if (string.IsNullOrEmpty(value)) continue;
if (Regex.IsMatch(value, #"C\+\+ 2012")) //here u can specify your version.
{
return true;
}
}
}
}
return false;
}
Dependencies:
using System.Text.RegularExpressions;
using Microsoft.Win32;
using System.Linq;

I use this one liner for PowerShell in Server 2019 and Windows 10. I'm do not know
how backward compatible this is.
Get-CimInstance -Class Win32_Product -Filter "Name LIKE '%Visual C++ %Redistri%'" | Select Name, Caption, Version

you can search in registry.Actually I do'nt have vs2012 but I have vs2010.
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.
HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86
HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64
HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\ia64
You can use registry function for that......

Related

Prerequisite condition for VC++ x86 runtime

I added VC++ 64 bit runtime prerequisite to my InstallShild project. File is downloaded from Microsoft page: https://aka.ms/vs/17/release/vc_redist.x64.exe
and has the following description: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.34.31931.
When this file is executed, it creates/updates the following Registry entry:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum, Version, 14.34.31931. Accordingly, I added the following Prerequisite Condition to InstallShield:
Everything is OK for x64. Now I want to add VC++ x86 runtime to the same project. File https://aka.ms/vs/17/release/vc_redist.x86.exe, description: Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.34.31931.
When this file is executed, it creates/updates the following Registry entry:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum, Version, 14.34.31931. I would like to make Prerequisite Condition by the same way, as for x64. But this doesn't work, because x64 installer actually creates two registry entries:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum and HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum, filling them by the same way. So, if x64 VC++ Runtime is already installed, x86 WOW6432Node condition doesn't work.
How can I solve this problem? The project has InstallScript type, so I can override installation events, if necessary. InstallShield version is 2018.
Try with the following registry keys:
For 64-bit setup,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64
Value: Version
For 32-bit setup,
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86
Value: Version
Condition type should be:

MSVCR110.dll is missing error on wamp running

I install the WAMP server on Windows 7 32 bit edition, but when I run this the error comes MSVCR110.dll is missing.
I install
Visual C++ 2010 SP1 Redistributable Package x86 : VC10 SP1 vcredist_x86.exe
from this location
But the problem is still and then i install Visual C++ 2008 from
But the problem is still here. Then I download visual c++ 2012 redistributable
but this is not install in my computer here is a log file
Log file
[043C:09FC][2014-09-15T15:50:26]: Burn v3.6.3542.0, Windows v6.1 (Build 7600: Service Pack 0), path: C:\Users\azeem\Downloads\vcredist_x64.exe, cmdline: ''
[043C:09FC][2014-09-15T15:50:26]: Setting string variable 'WixBundleLog' to value 'C:\Users\azeem\AppData\Local\Temp\dd_vcredist_amd64_20140915155026.log'
[043C:09FC][2014-09-15T15:50:26]: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\azeem\Downloads\vcredist_x64.exe'
[043C:09FC][2014-09-15T15:50:27]: Setting string variable 'WixBundleName' to value 'Microsoft Visual C++ 2012 Redistributable (x64) - 11.0.61030'
[043C:09FC][2014-09-15T15:50:27]: Detect 2 packages
[043C:09FC][2014-09-15T15:50:27]: Detected package: vcRuntimeMinimum_x64, state: Absent, cached: None
[043C:09FC][2014-09-15T15:50:27]: Detected package: vcRuntimeAdditional_x64, state: Absent, cached: None
[043C:09FC][2014-09-15T15:50:27]: Condition 'VersionNT64 >= v6.0 OR (VersionNT64 = v5.2 AND ServicePackLevel >= 1)' evaluates to false.
[043C:09FC][2014-09-15T15:50:27]: Error 0x81f40001: Bundle condition evaluated to false: VersionNT64 >= v6.0 OR (VersionNT64 = v5.2 AND ServicePackLevel >= 1)
[043C:09FC][2014-09-15T15:50:27]: Detect complete, result: 0x0`
According to wamp server official website, use the following link Visual Studio 2012 VC 11 vcredist_x64/86.exe
Please try to install these. These packages used for only Window 7 32 bit.
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)
Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)
Microsoft Visual C++ 2012 SP1 Redistributable Package (x86)
Please install first and restart your system then install and start WAMP server.
FWIW, none of these answers helped me.
This was due to broken links, mainly.
This site helped me out. It has a list of all the redistributables.
The one that I downloaded and fixed my problem was the 2012 one as the error is MSVCR110.dll which is Microsoft Visual C++ Redistributable Version 2011. So I decided that the next redist after 2011 would fix the problem.
I hope this helps others.

How to build with v90 platform toolset in VS2012 without VS2008, using Windows SDK?

I use Visual Studio 2012 and this is the only version of Visual Studio I have installed. I need to build certain C++ projects with the v90 platform toolset (of Visual Studio 2008), but I can't install Visual Studio 2008.
I understand it is possible to use the v90 platform toolset by installing Windows SDK 7.0. How exactly is it done? If I simply use the web installer of 7.0 SP1, I still don't see v90 as one of the possible platform toolsets.
It is possible, but apparently requires some maneuvering and will not support building MFC applications. The following assumes that VS2012 update 4 is installed, but neither VS2010 nor VS2008 are installed.
Download the x86 DVD of SDK 7.0 SP1 (GRMSDK_EN_DVD.iso). Mount the ISO or extract its contents, and manually install the MSI files from the following folders under the Setup folder:
WinSDK (this may fail, it's ok)
WinSDKBuild
WinSDKInterop
WinSDKTools
WinSDKWin32Tools
vc_stdx86
vc_stdamd64
winsdk_intellidocs
WinSDKIntellisenceRefAssys
WinSDKNetFxTools
Download the x86 DVD of SDK 7.1 (GRMSDK_EN_DVD.iso). Mount the ISO or extract its contents, and manually install the MSI files from the same folders listed above (except winsdk_intellidocs, which doesn't exist).
Go to C:\Program Files (x86)\Microsoft Visual Studio 9.0. Copy the following files from Common7\IDE to VC\bin:
msobj80.dll
mspdb80.dll
mspdbcore.dll
mspdbsrv.exe
Now you should be able to choose the v90 platform toolset in Visual Studio 2012 and build with it.
Explanations (and sources):
Individual MSI installation is based on the second workaround from this connect report.
The requirement for both 7.0 and 7.1 is based on this question (both VS2010 and VS2008 are required to use v90 in VS2012!). SDK 7.1 is not needed if you have VS2010.
DLL/EXE copying requirement is based on yet another question. If you do not copy them, you will see error MSB6006: "CL.exe" exited with code -1073741515.
In addition to this answer I want to add that
You can install SDK 7.0 simply by running setup, there is no problem with it.
You can install SDK 7.1 by running setup, if you remove Microsoft Visual C++ 2010 Redistributables first and fix following registry values:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client]
"Version"="4.0.30319"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full]
"Version"="4.0.30319"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Client]
"Version"="4.0.30319"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full]
"Version"="4.0.30319"
You can (and probably should) restore these values to whatever they originally were after installation is complete.
Do not forget to install KB2519277 after this, it updates compilers in SDK 7.1 to SP1.
You don't need to copy any dll. MSBuild uses
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VC#ProductDir
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC#ProductDir
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Setup\VS#ProductDir
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VS#ProductDir
to set up paths. It's probably wise to fix them to point to "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\" and "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\" as it might be useful elsewhere in build process.
Same goes for version 10.0 if you plan to use Windows7.1SDK toolset.
Use WindowsSdkVer.exe to set current SDK to 7.1 to defeat cryptic error in Microsoft.Cpp.x64.Targets(63,5) about missing unnamed required file. If the tool gives you error, then set these values manually:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows#CurrentInstallFolder
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows#CurrentInstallFolder
to point to newly installed SDK. The tool needs some registry keys from Visual Studio installation to work properly, but there are many and I'm not sure which are important.
Reboot. None of the above asks you to, but without reboot I got errors when trying to build a project.
As an aside, SDK7.1 adds v100 toolset, but it won't work, saying something about Could not find WindowsSDKDir variable from the registry. This is because v100 actually requires SDK7.0A which comes with Visual Studio 2010 and is not available separately. Windows7.1SDK toolset is the one which utilises VC2010 compilers if you need them.
Microsoft.Cpp.Win32.*.props files have a lot of relevant stuff if something fails in build system.
One addition/update for VS2013 to Yodans answer:
My working setup:
VS2013 has to use VS2010 libs
Using WinSDK 7.1 (Yodans 2.) build tools (v100) in VS2013
clean install, uninstalling everything mentioned in the sdk release notes (can be downloaded at http://www.microsoft.com/en-us/download/details.aspx?id=8279 under category Details)
Microsoft Windows SDK for Windows 7 (7.1) (the Windows SDK core-component files)
Application Verifier
Debugging Tools for Windows
Windows Performance Toolkit
Microsoft Help Viewer 1.0
Microsoft Visual C++ 2010 Redistributable
Microsoft Visual C++ 2010 Standard Edition
Additionally removed all .NET and VC++ related MS Software (not tested if necessary)
choosing Windows7.1SDK as Platform Toolset in VS2013
error MSB6006: "CL.exe" exited with code -1073741515
cl.exe uses msobj100.dll, mspdb100.dll, mspdbcore.dll and mspdbsrv.exe
Added to PATH C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
Build works and binary is usable ( So now its tested Yodan ;-) )
My mistake:
copied files in 7. above to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin (Yodans 3.), believing this dir is in PATH, but it was not!
So better do as sugested by Yodan and tested by myself in 8. above
p.s. same answer is solving this problem:
Visual Studio 2013: CL.exe exited with code -1073741515

InstallShield LE doesn't install MS Visual C++ 2010 Redistributable Package (x86)

I'm using InstallShield Limited Edition to create installer (setup.exe) for my project. My project requires Microsoft Visual C++ 2010 Redistributable Package (x86), and I want include this redist into my setup.exe. I do it in Redistributables view in my InstallShield project - just selecting Microsoft Visual C++ 2010 Redistributable Package (x86) as InstallShield Prerequisite component and setting 'Extract From Setup.exe' property for it.
I decided to test my setup.exe on XP box and Win7 box. For this purpose I deleted Microsoft Visual C++ 2010 Redistributable from these boxes (via Control Panel->Uninstall program) and tried to install my app. My expected result is - c++ redist will be installed before my project installation.
But I have different results: I have no problem when installing it on XP box: it installed c++ redist first and my app then. Works as it should be!
But when I launched setup.exe on Win7 box it didn't install c++ redist - it only installed my app. Can anyone explain this?
Btw, Microsoft Visual C++ 2010 Redistributable Package (x86) had size ~11 mb and version 10.0.40219 on my Win7 box before I uninstalled it. Now I downloaded it from here http://www.microsoft.com/en-us/download/details.aspx?id=5555, installed manually and... I see that now it has version 10.0.30319 and size only ~918 kb. So, I wonder again, what's going on?
This may be related to the operatingsystemconditions configuration in the Installshield pre-requisite file Microsoft Visual C++ 2010 Redistributable Package (x86).prq located in the Installshield SetupPrerequisites directory.
The operatingsystemconditions section specifies which versions of Windows, including service packs, 32/64 bits, the redistributable file should be installed on.
See http://daniellang.net/installshield-and-microsoft-visual-c-2010-redistributables/ for some more details.
You've installed the SP1 redist, but there is an updated version with a MFC security update.
http://support.microsoft.com/kb/2565063

Packaging Visual Studio 2012 Redistributable into an InstalLShield setup

I have developed a software with visual studio 2012 using the c++ language. I use Installshield 2010 Premier to build my setup project. I am trying to package the visual studio 2012 redistributable into the setup package so that it installs automatically. Is there a way to do this? I cannot find the redistributable in question on the redistributable page while configuring the installer.
Can I add it manually?
Any help would be appreciated.
P.S. Currently, I'm just manually running the redistributable I downloaded from Microsoft page before I run the setup.
Update to read first:
You need to install IS2012 SP1 to get these prereqs. See:
InstallShield 2012 Spring Service Pack 1 is Now Available!
Otherwise the PRQ XML can be found at:
x86 PRQ XML On Saturn
x64 PRQ XML On Saturn
Additional background information:
InstallShield comes with a prerequisite editor that you can use to define your own PRQ files. For a tutorial see:
Using InstallShield 12 to Install .NET Framework 3.0
Note: The PRQ schema hasn't changed in a long time. You can frequently install a trial version of InstallShield on a VM, find a new/updated PRQ and then back port it to your 2010 environment. Add it, build and test and it usually works fine. Also sometimes InstallShield will have expansion packs and addon installers to add these without rereleasing the product.
Use the redistributable merge modules (*.msm files) to integrate them into your setup. If you have Visual Studio installed you can find them at Program Files (x86)\Common Files\Merge Modules .

Resources