Silent install of Visual C++ Runtime 2010 using PowerShell

There is a ton of software out there that’s dependant on the Visual C++ 2010 Runtime, and I’ve gotten tired and annoyed with manually installing it on  just about every machine that I manage.  I create a PowerShell script that I can use to deploy the Visual C++ 2010 Runtime manually, with a login script, or using the Microsoft Deployment Toolkit.  Getting the installation files into a format that’s easy to deploy is a bit of a process, so I created a PowerShell script that will automatically download the Runtime source files, extract them, and generate the installer script for you.  You can view that script at the end of this post, but for now lets talk about the process of how we got there.

Step 1: Download the Redistributable Packages

Microsoft has released both an x86 and a 64-bit version of the runtime, and you might as well get them both and include them in your deployment script.  You can download these files from the links below and store them in a directory called something like VisualCPP2010Runtime.

Step 2: Extract the Packages

The two executables we just downloaded will unpack and then automatically run the installer.  We could just run an unattended install from these files, but then we need to wait for them to extract on every single device that needs them.  Open a command line and change to the directory containing the files, then execute the following two commands:

vcredist_x86.exe /extract:x86 /q
vcredist_x864.exe /extract:x64
 /q

This will extract both installers to separate directories for the separate processor architecture versions.

Step 3: Install the Runtimes

Finally you can install the runtime by issuing the following commands

x86\setup.exe /passive
x64\setup.exe /passive

or from PowerShell,

Start-Process -FilePath “x86\Setup.exe” -ArgumentList “/passive” -Wait -Passthru;
Start-Process -FilePath “x64\Setup.exe” -ArgumentList “/passive” -Wait -Passthru;

Putting it all together

The following script will take care of the entire process outlined above.  It will download and extract both versions of the Visual C++ 2010 Runtime and automatically generate a script called “unattend.ps1″ that you can execute (as an administrator, of course) to install the runtime on multiple computers in a variety of ways.

[rc_codebin snippet_id=”5252” ]