How to detect if Visual C++ 2017 Redistributable is installed

Viewed 37440

With Microsoft changing the pattern of registry entries in its latest versions, how do i detect if Visual C++ 2017 Redistributable is installed on a machine?

My aim is to install VC++2015Redist since the software is written using VS2015. If i can successfully detect VC++2017Redist on a machine, then I skip my installation of VC++2015Redist

4 Answers

VC redistributable is now joined for VisualStudio 2015-2019. If you try to install "older" one (e.g. just 2015) if you have any newer version (e.g 2017) you get error (end of this reply).

As @CJBS wrote, it writes itself to registries, but sadly I have noticed another place of record (so check it also):

For 32-bit VC++ Redistributable

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86

For 64-bit VC++ Redistributable

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64

I suggest to read @Bld DWord record and compare it to determine if you need more recent version: 2015 (Bld = 23026) 2017 (Bld = 26020) 2019 (Bld = 27820)


Error message image: 0x80070666 - Another version of this product is already installed. Installation of this version cannot continue...

# Check VCRedist current version
$OS= if ( ${env:ProgramFiles(x86)} ) {"\WOW6432Node"} else {"\"}
    $vcredist = Get-ItemProperty -Path "HKLM:\SOFTWARE$OS\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" -ErrorAction SilentlyContinue -ErrorVariable eVcRedist
if ($eVcRedist) {
    $Warning += @( "Abbyy FineReader 15 requires VCRedist." )
}
elseif (($vcredist.Bld -le 24215)) {
    $Warning += @( "Abbyy FineReader 15 requires VCRedist." )
}
Related