fix uninstall

This commit is contained in:
Kian 2024-05-10 18:17:12 -05:00
parent 5a98f63657
commit da2c8a1ca5
No known key found for this signature in database

View File

@ -12,9 +12,9 @@ function Invoke-WPFUnInstall {
return return
} }
$WingetInstall = (Get-WinUtilCheckBoxes)["Install"] $PackagesToInstall = (Get-WinUtilCheckBoxes)["Install"]
if ($wingetinstall.Count -eq 0) { if ($PackagesToInstall.Count -eq 0) {
$WarningMsg = "Please select the program(s) to install" $WarningMsg = "Please select the program(s) to install"
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) [System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return return
@ -22,21 +22,39 @@ function Invoke-WPFUnInstall {
$ButtonType = [System.Windows.MessageBoxButton]::YesNo $ButtonType = [System.Windows.MessageBoxButton]::YesNo
$MessageboxTitle = "Are you sure?" $MessageboxTitle = "Are you sure?"
$Messageboxbody = ("This will uninstall the following applications: `n $WingetInstall") $Messageboxbody = ("This will uninstall the following applications: `n $($PackagesToInstall | Format-Table | Out-String)")
$MessageIcon = [System.Windows.MessageBoxImage]::Information $MessageIcon = [System.Windows.MessageBoxImage]::Information
$confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) $confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
if($confirm -eq "No"){return} if($confirm -eq "No"){return}
Invoke-WPFRunspace -ArgumentList $WingetInstall -DebugPreference $DebugPreference -ScriptBlock { Invoke-WPFRunspace -ArgumentList $PackagesToInstall -DebugPreference $DebugPreference -ScriptBlock {
param($WingetInstall, $DebugPreference) param($PackagesToInstall, $DebugPreference)
$packagesWinget, $packagesChoco = {
$packagesWinget = [System.Collections.Generic.List`1[System.Object]]::new()
$packagesChoco = [System.Collections.Generic.List`1[System.Object]]::new()
foreach ($package in $PackagesToInstall) {
if ($package.winget -eq "na") {
$packagesChoco.add($package)
Write-Host "Queueing $($package.choco) for Chocolatey Uninstall"
} else {
$packagesWinget.add($package)
Write-Host "Queueing $($package.winget) for Winget Uninstall"
}
}
return $packagesWinget, $packagesChoco
}.Invoke($PackagesToInstall)
try{ try{
$sync.ProcessRunning = $true $sync.ProcessRunning = $true
# Install all selected programs in new window # Install all selected programs in new window
Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall -Manage "Uninstalling" if($packagesWinget.Count -gt 0){
Install-WinUtilProgramWinget -ProgramsToInstall $PackagesToInstall -Manage "Uninstalling"
}
if($packagesChoco.Count -gt 0){
Install-WinUtilProgramChoco -ProgramsToInstall $PackagesToInstall -Manage "Uninstalling"
}
$ButtonType = [System.Windows.MessageBoxButton]::OK $ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageboxTitle = "Uninstalls are Finished " $MessageboxTitle = "Uninstalls are Finished "