From 1bd4b1300a46719065573e1d25d12a2a2a719865 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:22:02 +0200 Subject: [PATCH 1/2] [MSI Prerequisites] Check for msi as well --- .../functions/Update-WAU.ps1 | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 index 4e4725f..efa851a 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -13,6 +13,7 @@ function Update-WAU { #Run WAU update try { + #Try WAU.zip (v1) #Force to create a zip file $ZipFile = "$WorkingDir\WAU_update.zip" @@ -68,13 +69,39 @@ function Update-WAU { catch { - #Send Error Notif - $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate" - $Message = $NotifLocale.local.outputs.output[4].message - $MessageType = "error" - Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text - Write-ToLog "WAU Update failed" "Red" + #Try WAU.msi (v2) + try { + #Download the msi + Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" + $MsiFile = "$env:temp\WAU.msi" + Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.msi" -OutFile $MsiFile + + + #Update WAU and run + Write-ToLog "Updating WAU..." "Yellow" + Start-Process msiexec.exe -ArgumentList "/i $MsiFile /qn /L*v ""$WorkingDir\logs\WAU-Installer.log"" RUN_WAU=YES" -Wait + + #Send success Notif + Write-ToLog "WAU Update completed. Rerunning WAU..." "Green" + $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" + $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion + $MessageType = "success" + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text + + Exit 0 + } + + catch { + + #Send Error Notif + $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate" + $Message = $NotifLocale.local.outputs.output[4].message + $MessageType = "error" + Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text + Write-ToLog "WAU Update failed" "Red" + + } } } \ No newline at end of file From 77dcf1b54eba41bba0e13647f034a2a381ab7c60 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:28:00 +0200 Subject: [PATCH 2/2] precision --- Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 index efa851a..2540eae 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -20,7 +20,7 @@ function Update-WAU { New-Item $ZipFile -ItemType File -Force | Out-Null #Download the zip - Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" + Write-ToLog "Downloading the GitHub Repository Zip version $WAUAvailableVersion" "Cyan" Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.zip" -OutFile $ZipFile #Extract Zip File @@ -72,7 +72,7 @@ function Update-WAU { #Try WAU.msi (v2) try { #Download the msi - Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" + Write-ToLog "Downloading the GitHub Repository MSI version $WAUAvailableVersion" "Cyan" $MsiFile = "$env:temp\WAU.msi" Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.msi" -OutFile $MsiFile