Detect Visual Studio C++ 2017

Hello,

I need to detect which machines of ours have Vistual Studio C++ 2017 installed. It looks like the minimum version of that should be 14.13. 26020 and based on patches installed, the minor and build numbers go up from there.What would the relevance look like to detect that minimum version or higher from:

HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64
HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86

HI @ptholt79 – it seems like version is stores in a version key value (as well as separately in major, minor, bld and rbld values).

This will return true only on systems with version equal to at least 14.13.26020

exists values "Version" whose (it as string as version >= "14.13.26020" as version) of keys ("HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64"; "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" ) whose (value "Installed" of it as string = "1") of x32 registry

I have also added a check for Installed = 1 to only check for installed instances.

Hope that helps!

2 Likes

Thanks for the reply. That did help.

Looking into this further, the versions of Visual Studio C++ on our machines are all over the place. We are attempting to install a call recording application that requires version 2015 x86 and x64 or earlier. We have some machines in the organization with this but also some that have 2017, 2019 and some with the combined version of 2015-2019.Trying to find a dynamic way to detect the higher versions and then remove them and install 2015. Thoughts?

The VC++ runtimes are generally installed as a prerequisite for other applications, and usually they require a specific version. I.E. removing VC++ 2019 may break whatever application required it. It’s common to have several versions on the same machine.

What’s usually important is to stay at the latest release level within a version. I.e. “if you have version 14, it should be at least 14.13.26020”. We would commonly handle that with a relevance query like

exists values "Version" whose (it as string as version = "14" and it as string as version < "14.13.26020" as version) of keys ("HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64"; "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" ) whose (value "Installed" of it as string = "1") of x32 registry

This would return True if version 14 is installed, but it’s below 14.13.26020 - you have a version 14 that is installed and should be patched to a higher build.

Alternatively, if you want to deploy VC 14 on systems that do not have an existing VC14 install, you might instead use

not exists values "Version" whose (it as string as version = "14" and it as string as version >= "14.13.26020" as version) of keys ("HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64"; "HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" ) whose (value "Installed" of it as string = "1") of x32 registry

The check for both version 14 and 14.0.26020 avoids the false-negative if VC2019 is installed (it fails to match the ’ version=“14” ’ part

2 Likes

Thanks once again for the reply. Yes, I did convey the concern about removing higher version of Visual Studio C++. I’ll see how this all works out.