Here are two simple Powershell scripts to automatic download and install all Visual C++ Runtimes for X86 and X64 Systems (2005, 2008, 2010, 2012, 2013, 2015).
Download the Visual C++ Runtime Modules:
<# .SYNOPSIS Download all "english" Visual C++ Runtimes .PARAMETER ParameterA $OutputPath = Default Path .LINK http://www.software-virtualisierung.de #> param( [String]$outputPath = ".\VCRuntime" ) Write-Host "Download Microsoft Visual C++ 2005, 2008, 2010, 2012, 2013, 2015" Write-Host "Andreas Nick, Software-Virtualisierung.de, 2015" if(! (test-path "$outputPath\VS2005X86SP1")) { New-Item "$outputPath\VS2005" -Type directory -Force} Write-Verbose "Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.EXE" -OutFile "$outputPath\VS2005\vcredist_x86.exe" Write-Verbose "Microsoft Visual C++ 2005 SP1 Redistributable Package (x64)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x64.EXE" -OutFile "$outputPath\VS2005\vcredist_x64.exe" if (! (test-path "$outputPath\VS2008")) { New-Item "$outputPath\VS2008" -Type directory -Force } Write-Verbose "Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x86.exe" -OutFile "$outputPath\VS2008\vcredist_x86.exe" Write-Verbose "Microsoft Visual C++ 2008 SP1 Redistributable Package (x64)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe" -OutFile "$outputPath\VS2008\vcredist_x64.exe" if (! (test-path "$outputPath\VS2010")) { New-Item "$outputPath\VS2010" -Type directory -Force } Write-Verbose "Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe" -OutFile "$outputPath\VS2010\vcredist_x86.exe" Write-Verbose "Microsoft Visual C++ 2010 SP1 Redistributable Package (x64)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe" -OutFile "$outputPath\VS2010\vcredist_x64.exe" if (! (test-path "$outputPath\VS2012")) { New-Item "$outputPath\VS2012" -Type directory -Force } Write-Verbose "Microsoft Visual C++ 2012 Update 4 Redistributable Package (x86)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exe" -OutFile "$outputPath\VS2012\vcredist_x86.exe" Write-Verbose "Microsoft Visual C++ 2012 Update 4 Redistributable Package (x64)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe" -OutFile "$outputPath\VS2012\vcredist_x64.exe" if (! (test-path "$outputPath\VS2013")) { New-Item "$outputPath\VS2013" -Type directory -Force } Write-Verbose "Microsoft Visual C++ 2013 Redistributable Package (x86)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x86.exe" -OutFile "$outputPath\VS2013\vcredist_x86.exe" Write-Verbose "Microsoft Visual C++ 2013 Redistributable Package (x64)" -Verbose Invoke-WebRequest "http://download.microsoft.com/download/2/E/6/2E61CFA4-993B-4DD4-91DA-3737CD5CD6E3/vcredist_x64.exe" -OutFile "$outputPath\VS2013\vcredist_x64.exe" if (! (test-path "$outputPath\VS2015")) { New-Item "$outputPath\VS2015" -Type directory -Force } Write-Verbose "Visual C++ Redistributable for Visual Studio 2015 (x86)" -Verbose Invoke-WebRequest "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe" -OutFile "$outputPath\VS2015\vcredist_x86.exe" Write-Verbose "Visual C++ Redistributable for Visual Studio 2015 (x64)" -Verbose Invoke-WebRequest "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe" -OutFile "$outputPath\VS2015\vcredist_x64.exe"
Install all Visual C++ Runtime Modules (run as Administrator)
<# .SYNOPSIS Install all "english" Visual C++ Runtimes .PARAMETER ParameterA $OutputPath = Default Path .LINK http://www.software-virtualisierung.de #> param( [String]$outputPath = ".\VCRuntime" ) [String]$outputPath = ".\VCRuntime" Write-Host "Install Microsoft Visual C++ 2005, 2008, 2010, 2012, 2013, 2015" Write-Host "Andreas Nick, Software-Virtualisierung.de, 2015" foreach ($vcFile in Get-ChildItem $outputPath -Recurse -Filter "*.exe") { Write-Host "Install " $vcFile.fullname Start-Process $vcFile.fullname -ArgumentList '/q' -NoNewWindow -Wait }
Kommentare 7
nice script thanks for sharing! what happen when you run it on a x86 machine? it looks like it will try to install x64 runtime anyway am I wrong?
thanks
Thank you my German Commraden! I was too lazy to install these piece by piece myself, so your script came in handy and proved to be very useful!!
Thanks a ton, saved me loads of time!
Thank you very much for uploading this script, managed to save me a lot of time, danke
It works, but I'm not a fan of the hard-coded URL's. Microsoft's landing page to download the restrib (e.g., for 2010 x64, https://www.microsoft.com/en-us/download/details.aspx?id=14632) provides a "Download" button that dynamically points to the latest version of that runtime. You'll find the download link it points to now is different than the URL hard-coded in your code.
Something like this would be more dynamic. All you need to know is the "id"
if (! (Test-Path "$outputPath\VS2010" -PathType Container)) { New-Item "$outputPath\VS2010" -Type Directory -Force }
Write-Verbose "Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)" -Verbose
$doc = Invoke-WebRequest "https://www.microsoft.com/en-us/download/confirmation.aspx?id=8328"
$url = ($doc.Links | ? {$_.OuterHTML -match 'http://download.microsoft.com/download'}).href
$fileName = Split-Path $url -leaf
Invoke-WebRequest "$url" -OutFile "$outputPath\VS2010\$fileName"
Write-Verbose "Microsoft Visual C++ 2010 SP1 Redistributable Package (x64)" -Verbose
$doc = Invoke-WebRequest "https://www.microsoft.com/en-us/download/confirmation.aspx?id=13523"
$url = ($doc.Links | ? {$_.OuterHTML -match 'http://download.microsoft.com/download'}).href
$fileName = Split-Path $url -leaf
Invoke-WebRequest "$url" -OutFile "$outputPath\VS2010\$fileName"
Hi Brian, good idea, I will rework the script
Because it took me quite some time to figure out the details, I post here my extension to the suggestion of "Brian" from 2017/01/13. The Version posted there doesn't work any more out of the box, since Microsoft changed their forms and the newer Redistributables use one common id for both x86 and x64 and arm...
My version only includes 2010, 2013 and 2015 because those are the ones I needed right now:
#################################################################
$outputPath = ".\VCRuntime"
if (! (test-path "$outputPath\VS2010")) { New-Item "$outputPath\VS2010" -Type directory -Force }
if (! (test-path "$outputPath\VS2013")) { New-Item "$outputPath\VS2013" -Type directory -Force }
if (! (test-path "$outputPath\VS2015")) { New-Item "$outputPath\VS2015" -Type directory -Force }
$progressPreference = 'silentlyContinue'
Write-Verbose "Microsoft Visual C++ 2010 Redistributable Package" -Verbose
$doc = Invoke-WebRequest "https://www.microsoft.com/en-US/download/confirmation.aspx?id=14632" -UseBasicParsing
$url = ($doc.Links | ? {$_.OuterHTML -match 'vcredist_x'}).href
$dlPath = (Split-Path $url |Select-Object -First 1) -replace "\\","/"
$filenames = (Split-Path $url -leaf|sort -Unique)
foreach ($vcFile in $filenames)
{
Write-Host "Download VC 2010: " $vcFile
Invoke-WebRequest "$dlPath/$vcFile" -OutFile "$outputPath\VS2010\$vcFile"
}
Write-Verbose "Microsoft Visual C++ 2013 Redistributable Package" -Verbose
$doc = Invoke-WebRequest "https://www.microsoft.com/en-US/download/confirmation.aspx?id=40784" -UseBasicParsing
$url = ($doc.Links | ? {$_.OuterHTML -match "vcredist_x}).href
$dlPath = (Split-Path $url |Select-Object -First 1) -replace "\\","/"
$filenames = (Split-Path $url -leaf|sort -Unique)
foreach ($vcFile in $filenames)
{
Write-Host "Download VC 2013: " $vcFile
Invoke-WebRequest "$dlPath/$vcFile" -OutFile "$outputPath\VS2013\$vcFile"
}
Write-Verbose "Microsoft Visual C++ 2015 Redistributable Package" -Verbose
$doc = Invoke-WebRequest "https://www.microsoft.com/en-US/download/confirmation.aspx?id=48145" -UseBasicParsing
$url = ($doc.Links | ? {$_.OuterHTML -match 'vc_redist.x'}).href
$dlPath = (Split-Path $url |Select-Object -First 1) -replace "\\","/"
$filenames = (Split-Path $url -leaf|sort -Unique)
foreach ($vcFile in $filenames)
{
Write-Host "Download VC 2015: " $vcFile
Invoke-WebRequest "$dlPath/$vcFile" -OutFile "$outputPath\VS2015\$vcFile"
}
#################################################################
Hope it helps somebody