From a64eda4ac7ba51043062964d51c0c7ad3fd21145 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:22:59 +0200 Subject: [PATCH 1/2] Improve MSI update from v1 --- .../functions/Update-WAU.ps1 | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 index 437d44c..68d10a5 100644 --- a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -96,17 +96,26 @@ function Update-WAU { } } + #Stop ServiceUI + $ServiceUI = Get-Process -ProcessName serviceui -ErrorAction SilentlyContinue + if ($ServiceUI) { + try { + Write-ToLog "Stopping ServiceUI" + $ServiceUI | Stop-Process + } + catch { + Write-ToLog "Failed to stop ServiceUI" + } + } + + #Uninstall WAU v1 + Write-ToLog "Uninstalling WAU v1" + Start-Process powershell -ArgumentList "-WindowStyle Hidden -ExecutionPolicy Bypass -Command `"$WorkingDir\WAU-Uninstall.ps1`"" -Wait + #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" - #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 } From 3cc8d7950e5e8bc99f4cb7c81f7939d69c437ebf Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:31:05 +0200 Subject: [PATCH 2/2] key not needed --- Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 index 68d10a5..bdd01a1 100644 --- a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -89,7 +89,7 @@ function Update-WAU { $properties = Get-ItemProperty -Path $sourcePath foreach ($property in $properties.PSObject.Properties) { #Check if the value name starts with "WAU_" - if ($property.Name -like "WAU_*") { + if ($property.Name -like "WAU_*" -and $property.Name -notlike "WAU_PostUpdateActions*") { #Copy the value to the destination key Set-ItemProperty -Path $destinationPath -Name $property.Name -Value $property.Value Write-ToLog "$($property.Name) saved."