2023-10-03 08:18:00 +00:00
|
|
|
function Update-WAU {
|
|
|
|
|
|
|
|
$OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases"
|
|
|
|
$Button1Text = $NotifLocale.local.outputs.output[10].message
|
|
|
|
|
|
|
|
#Send available update notification
|
|
|
|
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
|
|
|
|
$Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion
|
|
|
|
$MessageType = "info"
|
|
|
|
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
|
|
|
|
|
|
|
|
#Run WAU update
|
|
|
|
try {
|
2024-09-13 20:06:18 +00:00
|
|
|
#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
|
2023-10-03 08:18:00 +00:00
|
|
|
|
2024-09-13 20:06:18 +00:00
|
|
|
#Update WAU
|
2023-10-03 08:18:00 +00:00
|
|
|
Write-ToLog "Updating WAU..." "Yellow"
|
2024-09-18 10:57:39 +00:00
|
|
|
Start-Process msiexec.exe -ArgumentList "/i $MsiFile /qn /L*v ""$WorkingDir\logs\WAU-Installer.log"" RUN_WAU=YES INSTALLDIR=""$WorkingDir""" -Wait
|
2023-10-03 08:18:00 +00:00
|
|
|
|
|
|
|
#Send success Notif
|
2024-09-13 20:06:18 +00:00
|
|
|
Write-ToLog "WAU Update completed. Rerunning WAU..." "Green"
|
2023-10-03 08:18:00 +00:00
|
|
|
$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
|
|
|
|
|
2024-09-13 20:06:18 +00:00
|
|
|
exit 0
|
2023-10-03 08:18:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
catch {
|
|
|
|
|
2024-09-13 20:06:18 +00:00
|
|
|
#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"
|
2024-08-31 13:22:02 +00:00
|
|
|
|
2023-10-03 08:18:00 +00:00
|
|
|
}
|
|
|
|
|
2024-09-13 20:06:18 +00:00
|
|
|
}
|