检测是否安装了Visual Studio 2012的Visual C++ Redistributable

sea*_*717 103 visual-c++

如何检测Visual Studio 2012的Visual C++ Redistributable是否已安装?

我试过谷歌,没有人问这个问题,惊喜!

kay*_*eck 156

这取决于您使用的是什么版本.这两个2012密钥对我来说效果很好,他们的相应版本可以下载更新4.请注意,其中一些注册位置可能与操作系统有关.我从Windows 10 x64框中收集了这些信息.我只是要继续转储所有这些redist版本以及我搜索的用于检测安装的reg键:


Visual C++ 2005

Microsoft Visual C++ 2005 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182
Configuration: x64
Version: 6.0.2900.2180
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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])
Run Code Online (Sandbox Code Playgroud)

直接下载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])
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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
Run Code Online (Sandbox Code Playgroud)

直接下载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
Run Code Online (Sandbox Code Playgroud)

直接下载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
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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
Run Code Online (Sandbox Code Playgroud)

直接下载网址:https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe

版本警告:每个用户 Wai Ha Lee的发现,"... VC++ 2012更新4(11.0.61030.0)附带的二进制文件具有11.0.60610.1ATL和MFC二进制文件的版本,以及11.0.51106.1其他所有内容,例如msvcp110.dll和msvcr110.dll. .."


Visual C++ 2013

Microsoft Visual C++ 2013 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f} 
Configuration: x64
Version: 12.0.30501.0
Run Code Online (Sandbox Code Playgroud)

直接下载网址:https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/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
Run Code Online (Sandbox Code Playgroud)

直接下载网址:https://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe


Visual C++ 2015

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
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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
Run Code Online (Sandbox Code Playgroud)

直接下载网址:https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x86.exe


Visual C++ 2017

警告:有一个新的2017注册表公约正在使用,或者尚未最终确定.正如我猜测的最上面的键: [HKEY_CLASSES_ROOT\Installer\Dependencies\,,amd64,14.0,bundle][HKEY_CLASSES_ROOT\Installer\Dependencies\,,x86,14.0,bundle]

可能会有变化,或至少有不同的嵌套GUID,我将使用列表以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
Run Code Online (Sandbox Code Playgroud)

直接下载网址: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
Run Code Online (Sandbox Code Playgroud)

直接下载网址:https://download.visualstudio.microsoft.com/download/pr/d0b808a8-aa78-4250-8e54-49b8c23f7328/9c5e6532055786367ee61aafb3313c95/vc_redist.x86.exe


更新日志:
2018年12月14日-更新MSVC2008 Service Pack 1的的14.21.27702每吉姆·沃尔夫的研究结果更新
2018年11月27日-为MSVC2017 v更新的信息.9.0.30729.6161
2018年9月12日-增加了版本警告至2012年更新4每围下李的结论
八月2017年第24期 - 更新2017版的14.15.26706,更新后的Visual C++依赖项与VS 2017 15.8.1打包于
2018年5月16日 - 更新2017版的14.14.26405.0作为新的C++ 2017条目
2017年9月8日 -更新2017的14.11.25325.0版本作为新的Visual C++ 2017条目
2017年4月7日 - 更新2017版本的14.10.25008.0作为新的Visual C++ 2017条目
2016年10月24日 - 更新2015年版本信息14.0.24215.1
8月18日,2016 - 更新了2015年
5月27日14.0.24212的版本信息- 更新了MSVC2015更新2的信息

如果这些中的任何一个过时,请与我联系.

  • 太棒了.这是我发现的唯一一个在安装Visual Studio或卸载运行时时不会出现误报的内容. (4认同)
  • 不幸的是,这不包含VCREDIST 14.0 Update 2 - 我们如何处理前向兼容性(检测相同运行时的更新,更成功的版本) (4认同)
  • VS2015 Pre Update 1的GUID是{74d0e5db-b326-4dae-a6b2-445b9de1836e},因此您可以使用此机制进入pickle.对于每个未来的更新!启动安装了Update 1的预更新1 VCRedist给了我一个错误 - 所以我将使用VC安装程序reg键 - 如果你使用VCRedist似乎没问题? (2认同)
  • @ManjunathBabu,我不相信有关于Visual C++可再发行安装程序的注册表约定的任何外部文档.我只是注意到他们似乎实际上遵循了类似于2017年的方案,而不是仅仅在没有有意义的父键名的情况下抛出另一个GUID.到目前为止,他们已将这些位置用于2017年所有已发布的安装程序:`[HKEY_CLASSES_ROOT\Installer\Dependencies\,, x86,14.0,bundle\Dependents\{$ GUID}`和`[HKEY_CLASSES_ROOT\Installer\Dependencies\,, amd64,14.0,捆绑\家属\ {$ GUID}` (2认同)
  • Visual C++ 2017的新包更改注册表路径(版本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,捆绑]` (2认同)
  • 对于 VS2017,如果您只需要安装的版本,最好从以下位置的 Version 键读取:`HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64` 和 `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node \Microsoft\VisualStudio\14.0\VC\Runtimes\x86`。至少这样注册表路径不会总是改变。 (2认同)
  • 我为 v14.x <?foreach CPPRUNTIMEVERSIONPREFIX in 21;22;23;24;25;26;27;28;29;30;31;32;33;34; 的颠覆添加了一个循环(从 21 到 40) 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 ?> (2认同)

小智 31

尝试

HKLM\SOFTWARE\Microsoft\DevDiv\VC\Servicing\11.0
Run Code Online (Sandbox Code Playgroud)

作为一个起点.我将使用它作为安装VC++ 11(VS 2012)运行时的检查.

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vc\Servicing\11.0\RuntimeMinimum\Install应设置为1 (7认同)
  • 对于32位(aka x86),该键位于:`HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VC\Servicing\11.0\RuntimeMinimum` (3认同)

Mik*_*erk 25

您可以检查此注册表位置中的Installed1:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes\x86在64位系统上.在导致访问注册表项的代码中HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86.注意没有Wow6432Node.

在32位系统上,注册表是相同的,没有Wow6432Node:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86

  • 有趣的故事,没有来自MS的真实信息.我认为你到目前为止我已经发现了最好的答案.测试将vcredist安装在relativley新VM上,这是我之后发现的唯一密钥.所以从我身边大拇指...... (3认同)
  • 我有`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC`但我没有`Runtimes`键.我确实在Dave的答案`HKLM\SOFTWARE\Microsoft\DevDiv\VC\Servicing\11.0`中有密钥. (2认同)

She*_* 蒋晟 12

Visual C++附带的bootstrapper包清单中没有installcheck元素.猜猜如果你把它设置为先决条件,微软总是希望安装.

当然你仍然可以调用MsiQueryProductState来检查是否通过MSI安装了VC redist包.可以通过运行找到包代码

wmic product get
Run Code Online (Sandbox Code Playgroud)

在命令行,或者如果你已经在wmic:root\cli,运行

product where "Caption like '%C++ 2012%'"
Run Code Online (Sandbox Code Playgroud)


小智 10

遗憾的是,这个简单问题的答案并不简单,但在100%的系统中工作,甚至可以扩展到众多.net框架.

复杂性来自这样一个事实,即有许多VC运行时修订可能会导致虽然安装了VC10运行时,但它们的内部版本号不够新,因此除非你安装了非常的版本,否则你的EXE不会启动您需要的确切运行时间或其中一个较新的运行时,它们使相同主要版本的此版本和先前版本能够与它一起运行(并排地狱).此外,如果您有64位EXE,则必须同时检查32位和64位运行时.

也就是说,确定是否安装了EXE运行时的唯一可靠方法是尝试运行EXE - 或者使用与主EXE相同设置构建的另一个EXE,其唯一目的是执行 - 没有.只运行(这意味着安装了运行时)或无法运行(未安装时).

我为安装程序执行了以下操作,该安装程序需要安装VC10 32和64位运行时:安装程序尝试启动所有虚拟EXE,如果成功,则认为安装了相应的运行时.这也解决了32/64位方案.

顺便说一下,这也可以确定是否安装了正确的.net框架,这在Windows 8和10中非常棘手,因为可下载的内置.net 3.5支持也支持.net版本3.0和2.0 - 那里没有这些注册表项.(更糟糕的是,你甚至不能在这里使用标准的框架安装程序,你必须使用内置的支持并通过Windows下载它,或者用.net 4重建你的应用程序,但这是另一个故事).

可以使用具有以下代码的项目构建C++虚拟EXE(如果需要,可以使用64位配置中的另一个):

int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

记得设置项目的属性MFC的应用使用MFC共享DLL.可执行文件的大小约为4KB - 这是一个很小的代价,可以肯定的结果.

为了给您的用户提供良好的安装体验,您可以执行以下操作(示例代码适用于NSIS):

Function TryLaunchApplication
  Pop $1 ; pathname
  nsExec::Exec $1
  Pop $0

  ${If} $0 == "error"
  ${OrIf} $0 != 0
    Push 0
  ${Else}
    Push 1
  ${EndIf}
FunctionEnd
Run Code Online (Sandbox Code Playgroud)

并在函数中调用它,例如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
Run Code Online (Sandbox Code Playgroud)

然后启动运行时检查,例如离开欢迎页面并缓存结果时,每次用户单击"返回"和"下一步"按钮时都不必重新检查.

接下来,在安装树中创建一个只读部分,并在显示" 组件"页面之前执行的函数上预选或取消选择它.

这将确保每个缺少的运行时组件的安装是必需的,并且如果它已经存在则跳过.


BCr*_*ran 9

由于Visual Studio 2010及更高版本已停止使用WinSxS,因此仅检查%windir%\ system32\msvcr110.dll就足够了.如果要验证是否有足够新的版本,可以检查文件版本是11.0.50727.1(VS2012 RTM)还是11.0.51106.1(VS2012 Update 1).


Adr*_*uly 5

只需转到“控制面板”>“程序和功能”,它们就会全部显示在那里。

我不是专家,与人们回答的问题(检查注册表)相比,这个答案非常简单,所以我不确定这是否是正确的答案,但它对我有用。

程序和特点


TJ *_*ler 5

我遇到了这个问题,它在检查作为WiX创建的MSI安装程序一部分的Visual C ++可重新分发的上下文中寻找答案。

我不喜欢GUID随版本和操作系统的变化,所以我最终创建了一个用C#编写的自定义操作,以检查Visual C ++的可重新分发性。

下面的所有内容专门用于Visual C ++ 2015 Redistributable(x64),但可以轻松对其进行任何版本的修改。

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;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后在wxs文件中

<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>
Run Code Online (Sandbox Code Playgroud)

编辑 我正在使用有关创建和使用自定义操作的一些基本信息来更新此答案。

要在安装了WiX Toolset Visual Studio 2017扩展的Visual Studio 2017中创建自定义动作,我使用了项目模板来创建自定义动作(用于WiX v3的C#自定义动作项目)。

我检查了生成的项目,它似乎已经在本文开头列出了更改:https : //www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed因此,我在本节中选择了该文章,Adding Custom Action to the Installer并进行了一些调整。

我要做的另一件事是将针对项目构建的.NET框架的版本更改为3.5。

我没有发现它真的有用,但是您也可以看到http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html