Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSI Prerequisites] Check for msi version as well during WAU update #672

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ function Update-WAU {

#Run WAU update
try {
#Try WAU.zip (v1)

#Force to create a zip file
$ZipFile = "$WorkingDir\WAU_update.zip"
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
Expand Down Expand Up @@ -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 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



#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"

}
}

}
Loading