Installing Visual C++ Redistributable Package from Command Line

Warning! Some information on this page is older than 6 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Wed
20
May 2015

You may think that unless you explicitly use some external library (like FMOD), your program will not require any additional libraries to work, but when coding in C++ using Visual Studio, this is not the case. The functions of standard C/C++ library are implemented in a package of DLL-s called Microsoft Visual C++ Redistributable Package. Each version of Visual Studio has their own set. For example, version for Visual Studio 2013 (Release configuration) consists of files: msvcr120.dll, msvcp120.dll.

You can make your application not requiring this library by setting your project options in Configuration Properties > C/C++ > Code Generation > Runtime Library to "Multi-threaded [Debug]" without the "DLL" part, which makes it statically linked. Alternatively, you can distribute these DLL files (although I'm not sure if this is legal) or the whole library installer together with your application. The library is small and free, available to download from Microsoft website:

The question is: can you launch the installer of these packages with some special parameter so the user doesn't have to go through all the setup wizard, confirming each step? The answer is yes, but as Microsoft likes to change everything very often :) the exact command line is different depending on version. Here is the whole set:

Visual Studio 2005 (original one):

Visual Studio 2005, x86 (32-bit version):
vcredist_x86.exe /q:a /c:"VCREDI~1.EXE /q:a /c:""msiexec /i vcredist.msi /qn""
Visual Studio 2005, x64 (64-bit version):
vcredist_x64.exe /q:a /c:"VCREDI~2.EXE /q:a /c:""msiexec /i vcredist.msi /qn"" "
Visual Studio 2005 SP1, x86:
vcredist_x86.exe /q:a /c:"VCREDI~3.EXE /q:a /c:""msiexec /i vcredist.msi /qn"" "
Visual Studio 2005 SP1, x64:
vcredist_x64.exe /q:a /c:"VCREDI~2.EXE /q:a /c:""msiexec /i vcredist.msi /qn"" "

If you would like to install it in unattended mode (which will show a small progress bar but not require any user interaction), you can change the "/qn" switch above to "/qb". Unattended mode + disabled "Cancel" button is "/qb!".

Visual Studio 2005 (updated - the one I use):

/Q - quiet mode

Visual Studio 2008: Just pass one of these parameters:

/q - quiet mode, no user interface.
/qb - unattended mode, shows progress bar but no user interaction required.
/qb! - unattended mode with "Cancel" button disabled.

Visual Studio 2010 and 2012:

/q /norestart - quiet mode
/passive /norestart - passive (unattended) mode

Visual Studio 2013, 2015, 2017:

/install /quiet /norestart - quiet mode
/install /passive /norestart - passive (unattended) mode

To quickly install all of these libraries on the machines where lots of different applications are launched that may require them, I gathered all the libraries in one directory and I have written following BAT script:

"2005 Updated\vcredist_x86.exe" /Q
"2005 Updated\vcredist_x64.exe" /Q

"2008 SP1\vcredist_x86.exe" /qb
"2008 SP1\vcredist_x64.exe" /qb

"2010 SP1\vcredist_x86.exe" /passive /norestart
"2010 SP1\vcredist_x64.exe" /passive /norestart

"2012 Update 4\vcredist_x86.exe" /passive /norestart
"2012 Update 4\vcredist_x64.exe" /passive /norestart

"2013\vcredist_x86.exe" /install /passive /norestart
"2013\vcredist_x64.exe" /install /passive /norestart "2015 Update 3\vc_redist.x86.exe" /install /passive /norestart "2015 Update 3\vc_redist.x64.exe" /install /passive /norestart "2017\vc_redist.x86.exe" /install /passive /norestart "2017\vc_redist.x64.exe" /install /passive /norestart

Update: I also prepared a full package with my script and "pirated" copy of all these installers for your convenience: Microsoft Visual C++ Redistributable Package.zip (77.3 MB).

Update 2019-12-20: I've updated the package to contain latest redistributable installers for Visual Studio 2015/2017/2019, as described on Microsoft's page The latest supported Visual C++ downloads.

Comments | #c++ #visual studio Share

Comments

[Download] [Dropbox] [pub] [Mirror] [Privacy policy]
Copyright © 2004-2024