5

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

I'm using Nullsoft NSIS Installer System but only I need Windows Registry entry

I have googled, and looked at other StackOverflow questions. In particular, this Detect if Visual C++ Redistributable for Visual Studio 2012 is installed provides the exact Registry key to check, but for the case of VS 2012.

Community
  • 1
  • 1
Ivan Rodriguez
  • 426
  • 4
  • 14
  • Can't you just launch a silent install (which will do nothing if already installed) ? You'll need to ship the installer either way... – Calvin1602 Dec 09 '15 at 11:24
  • I only need windows registry entries for check Visual C++ version – Ivan Rodriguez Dec 09 '15 at 12:56
  • I find it easier to just always install vs. checking for installation for the VC Redist installers. The process is usually very fast if already installed. – crashmstr Dec 09 '15 at 12:58
  • @crashmstr exactly... OP, can you explain why you want to know if it's installed ? – Calvin1602 Dec 09 '15 at 13:01
  • The dll can't be included in the installer for business requirement. ;( – Ivan Rodriguez Dec 09 '15 at 13:10
  • @IvanRodriguez so if you detect that it is missing, are you going to just abort the installer or ask the user to download the redistributable on their own? You are not allowed by Microsoft to ship just the .dll but you are allowed to put the entire redistributable exe file inside your installer... – Anders Dec 09 '15 at 22:59
  • You can find the latest versions from most generations (as I'm writing this) from my answer here: https://stackoverflow.com/questions/12206314/detect-if-visual-c-redistributable-for-visual-studio-2012-is-installed/34209692#34209692 – kayleeFrye_onDeck Nov 02 '17 at 18:21

1 Answers1

6

My solution with NSIS system:

ReadRegDword $R1 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\VC\Runtimes\x64" "Installed"
ReadRegDword $R2 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\VC\Runtimes\x86" "Installed"
${If} $R1 != "1"
    ${AndIf} $R2 != "1"
        !insertmacro Log "Error: VisualStudio DLLs to the standard package (C++) 2013 is required!!"
        !insertmacro Log "Setup was not completed successfully."
        SetDetailsView show
        Abort 
    ${Else}
    !insertmacro Log "VisualStudio DLLs to the standard package (C++) 2013 is installed."

${EndIf}
Ivan Rodriguez
  • 426
  • 4
  • 14
  • 1
    It is better to check 'SOFTWARE\Microsoft\VisualStudio\12.0\VC\Runtimes\x86' – Mr.Angel May 25 '17 at 07:41
  • Ivan Rodriguez assumes it's running on a 64bit Windows, which makes it fail on all x86 Windows installations, @Mr.Angel answer is wrong on most x64 Windows installations, because they most of the time do not have the x86 VC redist installed. So as a consequence you will have to check the correct architecture according to the software for which you wrote the NSIS script is using. – user208383 Feb 06 '19 at 16:16
  • I checked my solution on x86 and x64. It works perfectly without checking architecture. – Mr.Angel Feb 21 '19 at 10:34
  • In my case, I had to install VC redist depending on the OS bitness, so I had to remove the "Wow6432Node" part from registry path which only exists on x64 systems. Nevertheless, thanks for the code ;) – Orsiris de Jong Jan 10 '20 at 23:55