mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-10 01:51:18 +10:00
yep
This commit is contained in:
@@ -1,37 +1,27 @@
|
|||||||
function Invoke-WPFAppxRemoval {
|
function Invoke-WPFAppxRemoval {
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Removes the selected AppX packages in a background runspace.
|
|
||||||
#>
|
|
||||||
|
|
||||||
if ($sync.ProcessRunning) {
|
if ($sync.ProcessRunning) {
|
||||||
$msg = "A process is currently running. Please wait for it to finish."
|
[System.Windows.MessageBox]::Show("A process is currently running.", "Winutil", "OK", "Warning")
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$selected = @($sync.selectedAppx)
|
$selected = @($sync.selectedAppx)
|
||||||
if ($selected.Count -eq 0) {
|
if (-not $selected) {
|
||||||
$msg = "Please select the AppX packages you wish to remove."
|
[System.Windows.MessageBox]::Show("Select AppX packages to remove.", "Winutil", "OK", "Warning")
|
||||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalSteps = $selected.Count
|
$apps = $sync.configs.appxHashtable
|
||||||
$completedSteps = 0
|
|
||||||
|
|
||||||
$handle = Invoke-WPFRunspace -ParameterList @(("selected", $selected), ("completedSteps", $completedSteps), ("totalSteps", $totalSteps)) -ScriptBlock {
|
Invoke-WPFRunspace -ParameterList @(("selected", $selected),("apps", $apps)) -ScriptBlock {
|
||||||
param($selected, $completedSteps, $totalSteps)
|
param($selected, $apps)
|
||||||
|
|
||||||
$sync.ProcessRunning = $true
|
$sync.ProcessRunning = $true
|
||||||
|
|
||||||
for ($i = 0; $i -lt $selected.Count; $i++) {
|
foreach ($key in $selected) {
|
||||||
$key = $selected[$i]
|
$package = $apps[$key].PackageId
|
||||||
$appInfo = $sync.configs.appxHashtable.$key
|
|
||||||
$packageId = $appInfo.PackageId
|
|
||||||
|
|
||||||
Write-Host "Removing $packageId"
|
Write-Host "Removing $package"
|
||||||
Get-AppxPackage -Name $packageId -AllUsers | Remove-AppxPackage -AllUsers
|
Get-AppxPackage -Name $package -AllUsers | Remove-AppxPackage -AllUsers
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync.ProcessRunning = $false
|
$sync.ProcessRunning = $false
|
||||||
|
|||||||
Reference in New Issue
Block a user