From a531af696b8570cae2b6825593fec7446370583b Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 10 Apr 2022 12:50:45 +0200 Subject: [PATCH] Add check for visual 2022 --- Winget-AutoUpdate-Install.ps1 | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 328539e..301d4dd 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -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{