How to install Microsoft VC++ redistributables silently in Inno Setup?

前端 未结 4 1620
灰色年华
灰色年华 2020-12-03 05:28

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 wi

相关标签:
4条回答
  • 2020-12-03 06:06

    Here is my solution:

    Filename: "{tmp}\vc_redist.x86.exe"; Parameters: "/q /norestart"; \
        Check: VCRedistNeedsInstall; StatusMsg: "Installing VC++ redistributables..."
    
    0 讨论(0)
  • 2020-12-03 06:16

    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.

    0 讨论(0)
  • 2020-12-03 06:19

    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.

    0 讨论(0)
  • 2020-12-03 06:21

    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:

    • http://www.computerhope.com/cmd.htm
    • http://blogs.msdn.com/b/astebner/archive/2014/03/08/10078468.aspx
    0 讨论(0)
提交回复
热议问题