From 4587ffaacad580e225f71aa65eee888c06dd0591 Mon Sep 17 00:00:00 2001 From: GabiNun2 Date: Sun, 21 Jun 2026 18:43:10 +0300 Subject: [PATCH] yep --- functions/public/Invoke-WPFAppxRemoval.ps1 | 32 ++++++++-------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/functions/public/Invoke-WPFAppxRemoval.ps1 b/functions/public/Invoke-WPFAppxRemoval.ps1 index 79bbcdcc..c5f8fa26 100644 --- a/functions/public/Invoke-WPFAppxRemoval.ps1 +++ b/functions/public/Invoke-WPFAppxRemoval.ps1 @@ -1,37 +1,27 @@ function Invoke-WPFAppxRemoval { - <# - .SYNOPSIS - Removes the selected AppX packages in a background runspace. - #> - if ($sync.ProcessRunning) { - $msg = "A process is currently running. Please wait for it to finish." - [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + [System.Windows.MessageBox]::Show("A process is currently running.", "Winutil", "OK", "Warning") return } $selected = @($sync.selectedAppx) - if ($selected.Count -eq 0) { - $msg = "Please select the AppX packages you wish to remove." - [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) + if (-not $selected) { + [System.Windows.MessageBox]::Show("Select AppX packages to remove.", "Winutil", "OK", "Warning") return } - $totalSteps = $selected.Count - $completedSteps = 0 + $apps = $sync.configs.appxHashtable - $handle = Invoke-WPFRunspace -ParameterList @(("selected", $selected), ("completedSteps", $completedSteps), ("totalSteps", $totalSteps)) -ScriptBlock { - param($selected, $completedSteps, $totalSteps) + Invoke-WPFRunspace -ParameterList @(("selected", $selected),("apps", $apps)) -ScriptBlock { + param($selected, $apps) $sync.ProcessRunning = $true - for ($i = 0; $i -lt $selected.Count; $i++) { - $key = $selected[$i] - $appInfo = $sync.configs.appxHashtable.$key - $packageId = $appInfo.PackageId + foreach ($key in $selected) { + $package = $apps[$key].PackageId - Write-Host "Removing $packageId" - Get-AppxPackage -Name $packageId -AllUsers | Remove-AppxPackage -AllUsers + Write-Host "Removing $package" + Get-AppxPackage -Name $package -AllUsers | Remove-AppxPackage -AllUsers } $sync.ProcessRunning = $false @@ -40,4 +30,4 @@ function Invoke-WPFAppxRemoval { Write-Host "-- AppX Removal Finished ---" Write-Host "=================================" } -} +} \ No newline at end of file