Add check for visual 2022

pull/49/head
Romain 2022-04-10 12:50:45 +02:00
parent 264d9a6816
commit a531af696b
1 changed files with 9 additions and 8 deletions

View File

@ -47,9 +47,10 @@ param(
<# FUNCTIONS #>
function Install-Prerequisites{
#Check if Visual C++ 2019 installed
$app = "Microsoft Visual C++*2019*"
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object { $_.GetValue("DisplayName") -like $app}
#Check if Visual C++ 2019 or 2022 installed
$Visual2019 = "Microsoft Visual C++*2019*"
$Visual2022 = "Microsoft Visual C++*2022*"
$path = Get-Item HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.GetValue("DisplayName") -like $Visual2019 -or $_.GetValue("DisplayName") -like $Visual2022}
#If not installed, ask for installation
if (!($path)){
@ -60,7 +61,7 @@ function Install-Prerequisites{
else{
#Ask for installation
$MsgBoxTitle = "Winget Prerequisites"
$MsgBoxContent = "Microsoft Visual C++ 2015-2019 is required. Would you like to install it?"
$MsgBoxContent = "Microsoft Visual C++ 2015-2022 is required. Would you like to install it?"
$MsgBoxTimeOut = 60
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent,$MsgBoxTimeOut,$MsgBoxTitle,4+32)
if ($MsgBoxReturn -ne 7) {
@ -80,22 +81,22 @@ function Install-Prerequisites{
$OSArch = "x86"
}
Write-host "Downloading VC_redist.$OSArch.exe..."
$SourceURL = "https://aka.ms/vs/16/release/VC_redist.$OSArch.exe"
$SourceURL = "https://aka.ms/vs/17/release/VC_redist.$OSArch.exe"
$Installer = $WingetUpdatePath + "\VC_redist.$OSArch.exe"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force)
Write-host "Installing VC_redist.$OSArch.exe..."
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
Remove-Item $Installer -ErrorAction Ignore
Write-host "MS Visual C++ 2015-2019 installed successfully" -ForegroundColor Green
Write-host "MS Visual C++ 2015-2022 installed successfully" -ForegroundColor Green
}
catch{
Write-host "MS Visual C++ 2015-2019 installation failed." -ForegroundColor Red
Write-host "MS Visual C++ 2015-2022 installation failed." -ForegroundColor Red
Start-Sleep 3
}
}
else{
Write-host "MS Visual C++ 2015-2019 wil not be installed." -ForegroundColor Magenta
Write-host "MS Visual C++ 2015-2022 wil not be installed." -ForegroundColor Magenta
}
}
else{