Merge pull request #49 from Romanitho/Visual2022

Add check for visual 2022
pull/51/head
Romain 2022-04-10 12:54:23 +02:00 committed by GitHub
commit 1edc5c6a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -47,9 +47,10 @@ param(
<# FUNCTIONS #> <# FUNCTIONS #>
function Install-Prerequisites{ function Install-Prerequisites{
#Check if Visual C++ 2019 installed #Check if Visual C++ 2019 or 2022 installed
$app = "Microsoft Visual C++*2019*" $Visual2019 = "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} $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 not installed, ask for installation
if (!($path)){ if (!($path)){
@ -60,7 +61,7 @@ function Install-Prerequisites{
else{ else{
#Ask for installation #Ask for installation
$MsgBoxTitle = "Winget Prerequisites" $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 $MsgBoxTimeOut = 60
$MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent,$MsgBoxTimeOut,$MsgBoxTitle,4+32) $MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent,$MsgBoxTimeOut,$MsgBoxTitle,4+32)
if ($MsgBoxReturn -ne 7) { if ($MsgBoxReturn -ne 7) {
@ -80,22 +81,22 @@ function Install-Prerequisites{
$OSArch = "x86" $OSArch = "x86"
} }
Write-host "Downloading VC_redist.$OSArch.exe..." 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" $Installer = $WingetUpdatePath + "\VC_redist.$OSArch.exe"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force) Invoke-WebRequest $SourceURL -OutFile (New-Item -Path $Installer -Force)
Write-host "Installing VC_redist.$OSArch.exe..." Write-host "Installing VC_redist.$OSArch.exe..."
Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
Remove-Item $Installer -ErrorAction Ignore 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{ 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 Start-Sleep 3
} }
} }
else{ 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{ else{