Skip to content

Instantly share code, notes, and snippets.

@jpbruckler
Created January 2, 2017 18:30
Show Gist options
  • Save jpbruckler/61a757e13e66fa1071a21402af678545 to your computer and use it in GitHub Desktop.
Save jpbruckler/61a757e13e66fa1071a21402af678545 to your computer and use it in GitHub Desktop.
Install all Visual C++ Redistributables in order
<#
This script expects all the redistributables to be in a folder structure like:
D:\DOWNLOADS
├───VS2005
│ vcredist_x64.exe
│ vcredist_x86.exe
├───VS2008
│ vcredist_x64.exe
│ vcredist_x86.exe
├───VS2010
│ vcredist_x64.exe
│ vcredist_x86.exe
├───VS2012
│ vcredist_x64.exe
│ vcredist_x86.exe
├───VS2013
│ vcredist_x64.exe
│ vcredist_x86.exe
└───VS2015
vc_redist.x64.exe
vc_redist.x86.exe
You can use the script that Mikael Nystrom wrote at https://deploymentbunny.com/2014/08/05/powershell-is-king-download-all-vc-runtimes-using-a-script/
to download the files int he appropriate directory structure.
Before running this script, change $BaseDir to point to the parent directory
holding the downloaded installers.
#>
$BaseDir = 'D:\Downloads'
$Files = @(
'VS2005\vcredist_x86.exe',
'VS2008\vcredist_x86.exe',
'VS2010\vcredist_x86.exe',
'VS2012\vcredist_x86.exe',
'VS2013\vcredist_x86.exe',
'VS2015\vc_redist.x86.exe',
'VS2005\vcredist_x64.exe',
'VS2008\vcredist_x64.exe',
'VS2010\vcredist_x64.exe',
'VS2012\vcredist_x64.exe',
'VS2013\vcredist_x64.exe',
'VS2015\vc_redist.x64.exe'
)
foreach ($File in $Files) {
$InstallFile = (Join-Path $BaseDir $File)
Write-Host ('Beginning install of {0}' -f $InstallFile)
try {
$Proc = Start-Process -FilePath $InstallFile -ArgumentList '/Q' -Wait -PassThru
Write-Host ('Process exited with RC: {0}' -f $Proc.ExitCode)
}
catch {
Write-Error ('Unable to install {0}' -f $InstallFile)
$PSItem.Exception
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment