Installing Visual C++ Redistributable Package from Command Line
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:
- 2005 SP1: x86, x64
- 2008 SP1: x86, x64
- 2010 SP1: x86, x64
- 2012 Update 4 (all versions)
- 2013 (all versions)
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:
* 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 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:
/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:
Sign up here with your email
1 comments:
Write commentsThanks... It saved my time. :ng:ng:ng:ng
ReplyConversionConversion EmoticonEmoticon