Add Install VC Redistributables script
parent
6ecbe9b0cf
commit
1d1078798f
|
|
@ -0,0 +1,38 @@
|
||||||
|
# URLs for the latest Visual C++ Redistributables
|
||||||
|
$urls = @(
|
||||||
|
"https://aka.ms/vs/17/release/vc_redist.x86.exe",
|
||||||
|
"https://aka.ms/vs/17/release/vc_redist.x64.exe"
|
||||||
|
# "https://aka.ms/vs/17/release/vc_redist.arm64.exe" # Uncomment if using Arm64 device
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
# Directory to save the downloads
|
||||||
|
$downloadPath = "$env:TEMP"
|
||||||
|
|
||||||
|
# To improve download performance, the progress bar is suppressed. [2, 6]
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
|
foreach ($url in $urls) {
|
||||||
|
$fileName = $url.Split('/')[-1]
|
||||||
|
$filePath = Join-Path $downloadPath $fileName
|
||||||
|
|
||||||
|
Write-Host "Downloading $fileName..."
|
||||||
|
# Download the file without a progress bar [1, 4]
|
||||||
|
Invoke-WebRequest -Uri $url -OutFile $filePath
|
||||||
|
|
||||||
|
if (Test-Path $filePath) {
|
||||||
|
Write-Host "Installing $fileName..."
|
||||||
|
# Silently install the redistributable and wait for it to complete [3, 5, 9]
|
||||||
|
Start-Process -FilePath $filePath -ArgumentList "/install /quiet /norestart" -Wait
|
||||||
|
Write-Host "$fileName has been installed."
|
||||||
|
# Optional: Remove the installer after installation
|
||||||
|
# Remove-Item -Path $filePath
|
||||||
|
} else {
|
||||||
|
Write-Host "Error: Failed to download $fileName."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Restore the default progress preference
|
||||||
|
$ProgressPreference = 'Continue'
|
||||||
|
|
||||||
|
Write-Host "Script execution finished."
|
||||||
Loading…
Reference in New Issue