Install VC_Redist 2015 Silently with InnoSetup

Posted on August 25, 2020 at 12:28 pm

First, download latest VC Redist 2015-2019 installer from here:

(Download Links) Visual Studio 2015, 2017 and 2019

In this example we will download x86: vc_redist.x86.exe

Rename it to VC_redist_2015_2019_x86.exe and place it inside \Redist\ folder.

In InnoSetup add this below [Files] section:

; VC++ redistributable runtime. Extracted only if needed, by checking if they are not installed
Source: "Redist\VC_redist_2015_2019_x86.exe"; DestDir: {tmp}; Check: VC2015RedistX86NeedsInstall; Flags: deleteafterinstall

Then add this below [Run] sections:

; Needed to install VC++ redistributables
Filename: "{tmp}\VC_redist_2015_2019_x86.exe"; StatusMsg: "Installing VC++ redistributables..."; Parameters: "/quiet /norestart"; Check: VC2015RedistX86NeedsInstall; Flags: waituntilterminated

Finally add this below [Code] section:

function VC2015RedistX86NeedsInstall: Boolean;
var 
  Version: String;
  RegKey: String;
begin
  RegKey := 'SOFTWARE\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum';
  if IsWin64 then RegKey := 'SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\14.0\RuntimeMinimum';
  if (RegQueryStringValue(HKEY_LOCAL_MACHINE, RegKey, 'Version', Version)) then
  begin
    // To check if VC 2015 are installed:
    // Is the installed version at least 14.0 ? (2015)
    // Visual C++ Redistributable for Visual Studio 2015 downloaded from:
    // https://www.microsoft.com/en-US/download/details.aspx?id=48145
    // Are versioned as 14.0.23026 in "Version" value
    Log('VC Redist Version check : found ' + Version);
    Result := (CompareStr(Version, '14.0.23026')<0);
 
    // To check if VC 2017 are installed:
    // Is the installed version at least 14.14 ? (2017)
    // Log('VC Redist Version check : found ' + Version);
    //Result := (CompareStr(Version, '14.14.26429.03')<0);
  end
  else 
  begin
    // Not even an old version installed
    Result := True;
  end;
  if (Result) then
  begin
    ExtractTemporaryFile('VC_redist_2015_2019_x86.exe');
  end;
end;

Receive updates via email

Other Posts

Updated Posts