Detect if Visual C++ Redistributable for Visual Studio 2012 is installed
Asked Answered
A

21

129

How to detect if Visual C++ Redistributable for Visual Studio 2012 is installed?

I tried Google it and nobody has asked this question, surprise!

Andersonandert answered 30/8, 2012 at 22:13 Comment(4)
Why not remove that dependency by setting Runtime library in C++ > Code generation to Multi-threaded [debug] instead of Multi-threaded [debug] dll? I just solved an issue of runtime redist installation by simply removing the dependecy.Sides
I found out how to detect packages by trial and error. I wish there was a magic bullet, but if there is, I haven't found it yet. I've got an answer down below for some specific redists that seem to work 100% of the time to help with currently most of them.Kristofor
Please consider changing the accepted answer to the one by kayleeFrye_onDeck. I have spent ages looking for a reliable method and this seems to be the one, I think with all the other unreliable answers it will help a lot of people to find the right informationStereotaxis
There seems to be an update for Visual Studio 2017 runtimes: 14.10.V25017. Link: go.microsoft.com/fwlink/?LinkId=746572 Could you update the registry values?Fanion
K
198

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

Kristofor answered 30/8, 2012 at 22:13 Comment(45)
This is perfect. This is the only one that I've found that doesn't give false positives when Visual Studio is installed or the runtime is uninstalled.Deformed
If this ever needs to be updated, please message me here. I usually check SO a couple times a week, if not more.Kristofor
VS2015 Pre Update 1's GUID is {74d0e5db-b326-4dae-a6b2-445b9de1836e} so you can get into a pickle with using this mechanism. For every future update! Launching the pre Update 1 VCRedist with Update 1 installed gave me an error - so I'm going to use the VC installer reg key - which seems to be fine if you use VCRedist?Ridley
I'm not sure how this method of direct-downloading is considered problematic, but yes, with MSVC 2015 redists, their installers don't allow you to install older versions, which can be quite annoying, especially if you're maintaining an installer that uses MSVC redists as a dependency. The second an updated redist comes out, the whole thing can go pear-shaped if you aren't careful. I'm not sure why they made this decision, but it breaks away from virtually all previous versions, except maybe 2010, IIRC.Kristofor
unfortunately this does not contain VCREDIST 14.0 Update 2 -- how do we deal with forward compatibility (detecting newer, succeeding versions of same runtime)Seabee
Great question, @ShaunWilson! It's been a pretty long time since I've done this, but I will try to get this updated for the answer for Update 2. IIRC, the reason I didn't share a common scheme was that it varied per generation.Kristofor
Okay, I've updated this answer for Update 2. In regards to methodology, it wasn't anything too clever. I simply kept track of the registry keys before and after installation/uninstallation.Kristofor
Warning: Today, an older version of MSVC2015's download URL stopped working. Previous generations of MSVC's links still work, so this is without precedent.Kristofor
I tried today to reinstall x64 2013 redistributables and got different path: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Dependencies\{1a63c099-febd-4eaf-83ad-a82ea4fdac49}. Although version is the same: 12.0.30501.0 Looks like it's not a reliable way too :(Surbase
It may be OS-dependent, @Surbase -- I will add the stipulation to this answer with my configuration. Please reply with yours, and I'll see if I can do anything about it.Kristofor
The GUIDs seem to vary, ie in Windows 10 x64, VC runtim 2015 Update 1 is on HKLM\Software\Classes\Installer\Dependencies\{e46eca4f-393b-40df-9f49-076faf788d83}Robtrobust
@FernandoGonzalezSanchez I'm pretty sure they change for each update. If you need a GUID from an earlier update, you may want to check the Edit History of this answer. I'm pretty sure I had update 1 in there at some time.Kristofor
@FernandoGonzalezSanchez It's now updated for the latest 2015 version.Kristofor
Does this really work for the case when this is uninstalled? I feel it would be better to check the Installed value from HKLM\SOFTWARE\ [ WOW6432Node\ ]Microsoft\Windows\CurrentVersion\Uninstall\{VCRedist_GUID_Here} .. or I am wrong?Calderon
@Calderon While there might be some schemes that are applicable for some generations of Visual C++, there are no universal schemes that I know of. If you find one for a specific generation or generations, I wouldn't be too surprised. I recall trying to find the same kind of trends before making this list. In regards to the accuracy of your statement, I would say to test it out. All the links to the various latest generations are above, so installing them and checking HKLM\SOFTWARE\ [ WOW6432Node\ ]Microsoft\Windows\CurrentVersion\Uninstall\{VCRedist_GUID_H‌​ere} should be quick enough.Kristofor
I've run into this problem where on a vanilla windows 8.1 install before applying any updates, the vs2015 redistributable will not install completely, but it will start to install and show up in the "add remove programs" list. So if you check for the guid, it is there, but there are lots of dlls missing, so programs that rely on it will fail to load. Any idea how to check for this scenario?Exurbanite
Is this an over-install of Windows, an upgrade, or a completely new image on a clean drive? If it's anything besides the latter, all kinds of weird behavior could be triggering. I would be very surprised is Visual C++ 2015 Redists came installed on vanilla Windows 8.1, as Win 8.1 came out April 2014 and the first Visual C++ 2015 Redist came out July 2015.Kristofor
It seems VC2017 is a binary compatible upgrade to 2015? I can't seem to install 2015 if 2017 is installed, and developercommunity.visualstudio.com/content/problem/14701/… seems to indicate that's intentional. Do we know if the 2017 version string is going to be standard there? I need my program to be forwards compatible now if they're going to do that.Sowers
Regarding compatibility, it will have to do with the toolset it was compiled with. VS2017 should default to 141 (vc2017) but should have the 140 (vc2015) option. It seems like the VC2015 binaries should be compatible with the VC2017 redists. Now, if that's all VC2015 apps, or ones built with specific versions like say, Update 3, that I can't tell you off the top of my head.Kristofor
@Kristofor : is VC++Redist2017 registry keys finalized? where do I find the above mentioned keys in official documentation?Garage
@ManjunathBabu, I don't believe there is any external documentation regarding registry conventions for the Visual C++ redistributable installers. I just noticed that they seemed to actually follow something resembling a scheme this time around for 2017, instead of just throwing another GUID somewhere without a meaningful parent key name. So far, they have used these locations for all the released installers for 2017: [HKEY_CLASSES_ROOT\Installer\Dependencies\,,x86,14.0,bundle\Dependents\{$GUID} and [HKEY_CLASSES_ROOT\Installer\Dependencies\,,amd64,14.0,bundle\Dependents\{$GUID}Kristofor
It might be necessary to replace HKLM with the full HKEY_LOCAL_MACHINE as HKLM does not work in a Installshield prq file on Windows 7.Alveolate
Note that 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. Not sure why.Vergeboard
The new package of Visual C++ 2017 change the registry path (Version 14.16.27012.6) [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x86,x86,14.16,bundle] [HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x64,amd64,14.16,bundle]Feud
@Kristofor Found a Microsoft Visual C++ Redistributable 2008 SP1 x64 EN should we add it to this list? Found it hereCapp
The custom action approach by TJ Rockefeller below is a much better approach in my opinion. You can check through the registry keys using logic like 2015, 2017, etc... very easily (assuming you're comfortable with creating custom actions).Porte
@DeweyVozel What you prefer, 1) does not work for all versions of Visual C++ and 2) requires use of Custom Actions, which while useful for things like WiX is not even applicable in a generic fashion. I mean, if you think this answer is bad that's one thing, but your preference is highly specific whereas mine is a generic one that only relies on the ability to access the Registry. Does the OP ask for a WiX solution? No. And yet you downvote my answer because it does not meet the preferred convenience of your specific use-case; seems a poor reason for a downvote to this question's answer.Kristofor
Pretty hostile, but not completely off-base. While the custom action answer is specific to an installer, it shows a more maintainable approach than having to constantly update what specific registry keys you're checking. The approach of iterating through the registry keys and checking the display name could be translated to several technologies easily and won't be nearly as brittle. For example, I used his approach to check that any version of either 2015 or 2017 are installed with little modification and I won't have to change my code when an update is pushed out that changes GUIDsPorte
You're mistaking my frustration with perceived hostility but this is text communication shrug From my POV you didn't seem to give any regard to the question for the answer you decided to, whatever you want to call it; I don't think you meant to come off as belittling. Back to the main topic; your preferred approach is not applicable to all versions of Visual C++ even in WiX-country. If you suggest a standalone C# app or class or something like that which actually does support all versions (2010 and earlier won't work with your/TJ Rockefellar's approach) that would be better IMO.Kristofor
I just tested using your registry options and they aren't always available. It depends on the version of the VC++ runtime that was installed. For example, I have 3 different 64 bit versions of 2013 on my machine. {050d4fc8-5d48-4b8f-8972-47c82c46020f} - 12.0.30501.0, {5d0723d3-cff7-4e07-8d0b-ada737deb5e6} - 12.0.40649.5 and {7f51bdb9-ee21-49ee-94d6-90afc321780e} - 12.0.21005.1. For Win32, I don't have the 30501 version but I do have the other two.Spencerspencerian
@Spencerspencerian thanks for the feedback. However, this answer explicitly refers to specific versions for each generation of VC++. Is there a reason you're expecting it to work for all versions?Kristofor
Unfortunately most questions asking about the VC++ runtimes are linked to this question. While the answer only refers to specific versions, it's useless of other versions. For example. the latest version of the C++ runtime for 2013 is 40649 so the whole 2013 section is outdated. This doesn't stand the test of time that we often ask for in SO answers (e.g. no link answers). They shouldn't become outdated. A better solution would be to scan through the registry keys looking for a string, searching for the .DLL file or alternatively, attempting to load the DLL in a controlled fashion.Spencerspencerian
@Spencerspencerian v 40649 is a download-only update/patch for VC++ 2013. That implies most users will never get it unless they either manually download it or something they install does it for them. Do you really think a non-WU redist should take precedence over a WU redist when taking automation into account?Kristofor
@Spencerspencerian I think you're missing the context of why this answer is so widely used to begin with for detecting VC++. It's because of Wix. You can't really do much dynamically with a basic Wix installer when it comes to dependency-detection. Most things to check have to be done so statically. Even if Wix allowed dynamic queries for its dependency mechanisms, it would slow the installation process. Who wants a slower installer? I get your frustrations but the context here is quite specific. Also, DLL-detection doesn't work for all gens.Kristofor
I am not saying that anything should take precedence. The question asks how to detect if the visual c++ redist is installed. It doesn't ask for a particular version. It doesn't matter whether I have 40649 or 21005 installed. The result of the test should be true. The question has nothing to do with Wix. In my case, I needed to check for the runtime before attempting loading a different DLL at runtime because the DLL displays a nasty message when it's missing. My question is identical to the one here. "How do I check if the redist is installed". Why people are doing that check isn't relevant.Spencerspencerian
Hey there @Graymatter. I get the point you're trying to make, but it doesn't actually address what I said directly. My points were about the answer, not the question, and please understand that I never asked for this answer to become the defacto redirect for all VC++ installation detection questions. The community did that on their own. I tried to explain why the answer is popular (Wix) and whether or not you consider that relevant to your specific challenge doesn't matter because I wasn't addressing your specific challenge, just explaining why this answer became so popular.Kristofor
For VS2017, if you only need the version installed, it is might be better to read from the Version key in: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64 and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86. At least that way the registry path is not always changing.Lumenhour
For 2019 there is short url available aka.ms/vs/16/release/vc_redist.x64.exe aka.ms/vs/16/release/vc_redist.x86.exeHarlie
Should the Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.22.27821 be Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.22.27821? Registry Key, Configuration, and Links are correct but description is duplicated.Beggar
support.microsoft.com/en-us/help/3179560/… has 2013 which has version 12.0.40660.0Beggar
Can you update a reference document about where to find those registry key(GUID) for each version?Burford
I added a loop (from 21 to 40) for the subversions of v14.x <?foreach CPPRUNTIMEVERSIONPREFIX in 21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36;37;38;39;40?> <RegistrySearch Id="mfc14$(var.CPPRUNTIMEVERSIONPREFIX)x86" Root="HKCR" Key="Installer\Dependencies\VC,redist.x86,x86,14.$(var.CPPRUNTIMEVERSIONPREFIX),bundle" Type="raw" /> <?endforeach ?>Interior
I downloaded & installed the latest 2015-2019 package (v 14.25.28508). It's reg values are: HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x64,amd64,14.25,bundle\Dependents\{6913e92a-b64e-41c9-a5e6-cef39207fe89} & HKEY_CLASSES_ROOT\Installer\Dependencies\VC,redist.x86,x86,14.25,bundle\Dependents\{65e650ff-30be-469d-b63a-418d71ea1765}. I can't add them, since the suggested edit queue is full. Downloaded these here: x86 x64.Stamper
Also I got different values for the 2012 update 4 redist: {4fd02573-5f12-4ae4-8027-c63f8e1115af} for x86 & {b341426f-8543-4e0d-96c3-e976f8ec5ab6} for x64.Stamper
@Kristofor is da real mvp here :-) tyvm! I was trying to figure out how to test the presence of these and overcomplicating the matter (like I do). It's much simpler than I thought: if (!(test-path HKLM:\SOFTWARE\Classes\Installer\Dependencies\"{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}")){echo "VCRedist 2012 x64 not found"} Put the guids in a hashtable of kv pairs with the versions and you can test for any and all of them quickly, and probably even do stuff like download them and install them if not found.Howlett
B
31

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.

Bertolde answered 28/1, 2013 at 14:30 Comment(4)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\11.0\RuntimeMinimum\Install should be set to 1Later
For 32-bit (aka x86) the key is located at: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VC\Servicing\11.0\RuntimeMinimumRimrock
@Kristofor have you found how to do this? I'm still looking for a reliable way as well, but none of the answers on this page have worked for meDeformed
Better answer than the accepted one as it does not rely on package UUID, likely to change for every patch Microsoft providesDeli
L
29

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

Laubin answered 14/2, 2013 at 15:28 Comment(11)
I have a 32-bit Win7 machine with the 2012 VC++ runtime installed and I do not have this reg key.Mahratta
Are you sure you dont have `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC`? What do you have?Laubin
I have HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC but I don't have the Runtimes key. I do have the key in Dave's answer HKLM\SOFTWARE\Microsoft\DevDiv\VC\Servicing\11.0.Mahratta
@Mahratta Odd that each system can be so different... Thanks for adding this useful infoLaubin
Funny story and no real info from MS. I think you have the best answer I've spotted so far. Tested to install the vcredist on a relativley fresh VM and this is the only key I found afterwards. So thumb up from my side...Scavenge
@Mahratta I know you posted quite a while ago but what registry view were you looking in: 32 or 64bit? I see "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\..." in the 32bit registry view but not in the 64bit view. Actually "\VisualStudio\11.0\VC\Runtimes\..." does not appear at all in the 64bit view so that key may only be in the 32bit view. This is on a Windows 7 x64 machine without visual studio installed (I have it installed in a VM).Effendi
I just checked in my Windows 8.1 VM where I have Visual Studio 2013 installed. I do have the "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\12.0" in the 64bit view. Don't have the VC portion though. It's 12.0 instead of 11.0 since I have 2013 visual studio installed instead of the 2012 version. So people may be looking on a machine with Visual Studio installed and that's confusing things.Effendi
@Mahratta Sorry didn't read your comment carefully. You had a 32bit machine. Please ignore.Effendi
@Effendi I now have a 64-bit machine and I see that key exists in my redirected win32 location. HOWEVER, I wonder if also the difference was in how the files were installed. For example, I think on my previous Win32 machine I had VS2012 installed. Now I have VS2013 installed on my 64-bit machine. So maybe on my previous pc the files were installed differently by Visual Studio and on my current pc the files were installed by the actual redist installer. Actually, that doesn't make sense because I assume MS would use the same redist installer in both cases, but it's just a guess.Mahratta
I can confirm that in a VM with VS2015 installed as well as a clean VM with VCRedist that HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86 is present. To me, this mechanism is preferable than the registry installer GUID check below, as updates of VCRedists of 14.0 seem to have new product IDs. You can't have more than one vc14 installed at a time, but they are backward/forward compatible within v14.0.*. So just checking any 14.0 is installed is good enough.Ridley
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86 exists even if vs2017 runtimes are uninstalled. So please don't use this - this registry key is unreliable !Trotskyism
M
14

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%'"
Malamud answered 31/8, 2012 at 6:52 Comment(0)
H
10

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.

Heinrich answered 12/11, 2014 at 10:5 Comment(1)
Thank you for helpful tip, do you remember what type of the project has to be created? VS has plethora of them to choose from :-).Queridas
L
9

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).

Lozengy answered 29/1, 2013 at 1:5 Comment(5)
+1 this is simpler and more foolproof. Registry keys are all fine and such, but if the user messed with the system and deleted msvcr110.dll the registry check is useless. It's best to check for all components you need though (msvcr110.dll, msvcp110.dll, mfc, ...). And for update 3 the version is 11.0.60610.1.Medlar
ok ignore that last bit: seems only the installer is 11.0.60610.1, the version of the crt dlls is still 11.0.51106.1Medlar
ya the .dll is 11.0.51106.1 even though I have vs2012 sp4 installedVonvona
This won't work. I uninstalled 2005-2015, and I still have msvc files for 60, 100, 110, 120, and 140 there.Kristofor
Note that 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. Not sure why. You can confirm this (on the Windows 10 machines I've tested it on) by going to C:\ProgramData\Package Cache\{BD95A8CD-1D9F-35AD-981A-3E7925026EBB}v11.0.61030\packages\vcRuntimeMinimum_x86 and C:\ProgramData\Package Cache\{B175520C-86A2-35A7-8619-86DC379688B9}v11.0.61030\packages\vcRuntimeAdditional_x86 then inspecting the files in the .cab files.Vergeboard
N
5

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.

Programs and Features

Needham answered 25/11, 2014 at 19:21 Comment(1)
This is probably the most direct answer to the original post!Dossier
S
5

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

Stefanstefanac answered 16/5, 2017 at 18:58 Comment(0)
D
4

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).

Dioxide answered 19/9, 2013 at 13:8 Comment(2)
This answer is exactly what we were looking for (versus other answers here, which are less about the runtime, and more about Visual studio, unfortunately.)Seabee
This answer doesn't work, as this key exists after you've uninstalled the redists.Kristofor
M
3
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
Maund answered 29/11, 2013 at 20:26 Comment(0)
F
3

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

Fecteau answered 9/1, 2015 at 8:0 Comment(2)
This is untrue. Keys exist in both locations when they've been uninstalled.Kristofor
@Kristofor Yep... I must agree with you. But in fact, when i tried it first time, it was successful. But recently it is like you said. I don't know why it is like that.Fecteau
J
3

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.

Jovian answered 24/6, 2016 at 15:17 Comment(4)
How did you get this information? And is that the UpgradeCode for the x86 version or the x64 version?Marquardt
You can use Orca to open up the msi and extract the UpgradeCode. The one given here is for x86 at least. As for where I got the rest of the information, this is pretty much the primary source; I couldn't find other references to this approach online regarding the redist specifically, but the UpgradeCode / family pattern is common with MSI installers.Jovian
I am aware of Orca. The problem has to do with getting to that MSI. I do not know of a way to directly access it. The only way that I know of is to somehow find it in the c:\Windows\Installer directory. I have over 1,000 files in that directory. The files are named randomly. The only way to determine which MSI is correct is to look at the description. This involves hitting Alt+Enter on 1,000 files in explorer or using a tool to dump the descriptions of 1,000 files.Marquardt
Ahh I see. You can search the registry as well to find the path or even the upgradecode if you know the productcode, within HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UpgradeCodes. However you may need to use WMIC (or some other programmatic access to the msi db) to figure out the rest. wmic product get /format:csv will dump a csv you can search - it has the msi paths in the returned values. You could write a better script I am sure but this should be enough to get you on your way.Jovian
W
3

This PowerShell code should do the trick

Get-ItemProperty
HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Format-Table –AutoSize
Wharton answered 8/12, 2016 at 21:13 Comment(1)
because hardcoding a bunch of product codes wasn't going to fly, we too enumerate the registry checking the "productname" of each entry with a regex, we then check VersionMajor/VersionMinor (which is all we really care about) this has the value of allowing us to produce a single build and know that it will continue working over the servicing life of a given vcredist version. the intent here is spot-on, but may require transliteration for toolsets like NSIS or WinAPI-based installers.Seabee
R
2

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.

Russell answered 27/2, 2014 at 14:17 Comment(0)
B
2

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.

Bunion answered 26/8, 2015 at 6:53 Comment(0)
C
1

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
Calderon answered 2/2, 2017 at 16:40 Comment(0)
D
0

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
Desouza answered 7/2, 2017 at 18:15 Comment(0)
C
0

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.

Capp answered 8/1, 2019 at 13:31 Comment(0)
M
0

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;
Mazman answered 22/2, 2020 at 17:27 Comment(0)
U
0

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
Untutored answered 29/3, 2021 at 21:6 Comment(0)
A
-5

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......

Afra answered 31/8, 2012 at 6:48 Comment(6)
I have write that in first line "That I do'nt have VS2012". So no need to comment this.............And this was only for vs2010Afra
You did note that, but it seemed as if you were suggesting that your solution may work for VS2012 as well since that was the OP's question (but couldn't verify since you don't have VS2012). I was simply stating that this approach does not, in fact, work with VS2012 since I checked it out.Gleda
Why down vote my answer......I have write clear that it is for vs2012...and this is accepted as answer by user....so why???????????Afra
It seems that with a x64 bit OS this value is located at HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\VC\VCRedist\...Rogue
VS 2012 keys are HKLM\SOFTWARE\Microsoft\VisualStudio\11.0\VC\RunTimes____ HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\RunTimes___Gilligan
Why the down-vote? The question clearly states they are trying to determine if VS2012 redistributable is installed and not VS2010. Your attempt at an answer doesn't answer the question even if you said it was only for 2010... Wrong Answers dilute the value of Stack Exchange... We don't want another Experts Exchange...Sudderth

© 2022 - 2024 — McMap. All rights reserved.