15

How to install Microsoft VC++ redistributables silently in Inno Setup? I used the following code, most of the installation part is silent except the installation progress window.

Here is my [Run] section's code:-

[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
    Parameters: "/passive /verysilent /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
    Check: VCRedistNeedsInstall; WorkingDir: {app}\bin;Flags: runminimized nowait; \
    StatusMsg: Installing CRT...
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Myanju
  • 1,135
  • 1
  • 11
  • 23

4 Answers4

12

You can add those to the setup script:

[Files]
Source: "vcredist_x86.exe"; DestDir: {tmp}; Flags: deleteafterinstall

[Run]
Filename: {tmp}\vcredist_x86.exe; \
    Parameters: "/q /passive /Q:a /c:""msiexec /q /i vcredist.msi"""; \
    StatusMsg: "Installing VC++ 2008 Redistributables..."

Note that the run parameters will change slightly, if you are using a different redistributable version from 2008.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Thunder
  • 2,994
  • 1
  • 24
  • 19
  • Can u tell me for c++ 2005? what would be the parameter? – Kushal Jul 19 '16 at 17:36
  • @Kushal This post from microsoft website will probably help you: https://blogs.msdn.microsoft.com/astebner/2007/02/07/update-regarding-silent-install-of-the-vc-8-0-runtime-vcredist-packages/ – Thunder Mar 26 '17 at 08:53
12

For a smooth install, check if it's necessary to install the redistributable. If the installed version is already up to date (quite likely), don't even unpack it.

[Files]
; VC++ redistributable runtime. Extracted by VC2017RedistNeedsInstall(), if needed.
Source: ".\Redist\VC_redist_2017.x64.exe"; DestDir: {tmp}; Flags: dontcopy

[Run]
Filename: "{tmp}\VC_redist_2017.x64.exe"; \
  StatusMsg: "{cm:InstallingVC2017redist}"; \
  Parameters: "/quiet"; Check: VC2017RedistNeedsInstall; Flags: waituntilterminated
[Code]
function VC2017RedistNeedsInstall: Boolean;
var 
  Version: String;
begin
  if RegQueryStringValue(HKEY_LOCAL_MACHINE,
       'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Version',
       Version) then
  begin
    // Is the installed version at least 14.14 ? 
    Log('VC Redist Version check : found ' + Version);
    Result := (CompareStr(Version, 'v14.14.26429.03')<0);
  end
  else 
  begin
    // Not even an old version installed
    Result := True;
  end;
  if (Result) then
  begin
    ExtractTemporaryFile('VC_redist_2017.x64.exe');
  end;
end;

Note that the 14.14 redistributable is also suitable for VS2015.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
MSalters
  • 173,980
  • 10
  • 155
  • 350
  • 1
    Is there any way to download them while installing instead of including them with installer. It will reduce size of installer. –  Nov 04 '19 at 07:33
  • @user8123187 Hope this will help https://www.codeproject.com/Articles/20868/NET-Framework-Installer-for-InnoSetup?msg=4979480#xx4979480xx – yashodha_h Nov 22 '19 at 06:54
  • Instead of `Flags: dontcopy`, reuse the `Check: VC2017RedistNeedsInstall` – and you won't need to explicitly extract the file using `ExtractTemporaryFile` – The `Check` function can (and is) called multiple times, so it should not do expensive operations. – Martin Prikryl Jun 08 '20 at 05:40
  • 1
    The use of `CompareStr` is rather fragile. You might instead use [my `CompareVersion` function](https://stackoverflow.com/q/37825650/850848) like: `Result := (Copy(Version, 1, 1) = 'v') and (CompareVersion(Copy(Version, 2, Length(Version) - 1), '14.14.26429.03') < 0)` – Martin Prikryl Jan 20 '23 at 12:07
  • 1
    I've tried this script with success for x64 redistributable. This doesn't work for x86, though, since there is no `Version` key in 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86' (probably due to this bug https://developercommunity.visualstudio.com/t/vc-runtime-redistributable-update-deletes-registry/262841). The key can be instead found in 'SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86'. One can also check x64 key in the relative 'x64' path. – il_mix Jul 31 '23 at 08:20
3

I modified the above code as follows. Then I got it worked properly and the entire installation was pretty smooth and silent.

[Run]
Filename: "{app}\bin\vcredist_x86.exe"; \
    Parameters: "/q /norestart /q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; \
    Check: VCRedistNeedsInstall; WorkingDir: {app}\bin;

Reference Links:

li ki
  • 342
  • 3
  • 11
Myanju
  • 1,135
  • 1
  • 11
  • 23
1

Here is my solution:

Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
    Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Heidi
  • 161
  • 5
  • 16