2023-05-09 13:14:27 -05:00
|
|
|
function Invoke-WPFUnInstall {
|
|
|
|
<#
|
2023-10-19 17:12:55 -05:00
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
Uninstalls the selected programs
|
|
|
|
|
2023-05-09 13:14:27 -05:00
|
|
|
#>
|
|
|
|
|
|
|
|
if($sync.ProcessRunning){
|
2023-10-04 10:22:21 -05:00
|
|
|
$msg = "Install process is currently running"
|
2023-05-09 13:14:27 -05:00
|
|
|
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-10-04 10:22:21 -05:00
|
|
|
$WingetInstall = Get-WinUtilCheckBoxes -Group "WPFInstall"
|
2023-05-09 13:14:27 -05:00
|
|
|
|
|
|
|
if ($wingetinstall.Count -eq 0) {
|
|
|
|
$WarningMsg = "Please select the program(s) to install"
|
|
|
|
[System.Windows.MessageBox]::Show($WarningMsg, $AppTitle, [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
$ButtonType = [System.Windows.MessageBoxButton]::YesNo
|
|
|
|
$MessageboxTitle = "Are you sure?"
|
2023-10-19 17:12:55 -05:00
|
|
|
$Messageboxbody = ("This will uninstall the following applications: `n $WingetInstall")
|
2023-05-09 13:14:27 -05:00
|
|
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
|
|
|
|
|
|
|
$confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
|
|
|
|
|
|
|
if($confirm -eq "No"){return}
|
|
|
|
|
2023-10-04 10:22:21 -05:00
|
|
|
Invoke-WPFRunspace -ArgumentList $WingetInstall -scriptblock {
|
|
|
|
param($WingetInstall)
|
2023-05-09 13:14:27 -05:00
|
|
|
try{
|
|
|
|
$sync.ProcessRunning = $true
|
|
|
|
|
2023-10-19 17:12:55 -05:00
|
|
|
# Install all selected programs in new window
|
2023-05-09 13:14:27 -05:00
|
|
|
Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall -Manage "Uninstalling"
|
|
|
|
|
|
|
|
$ButtonType = [System.Windows.MessageBoxButton]::OK
|
|
|
|
$MessageboxTitle = "Uninstalls are Finished "
|
|
|
|
$Messageboxbody = ("Done")
|
|
|
|
$MessageIcon = [System.Windows.MessageBoxImage]::Information
|
2023-10-04 10:22:21 -05:00
|
|
|
|
2023-05-09 13:14:27 -05:00
|
|
|
[System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
|
|
|
|
|
|
|
|
Write-Host "==========================================="
|
2023-10-19 17:12:55 -05:00
|
|
|
Write-Host "-- Uninstalls have finished ---"
|
2023-05-09 13:14:27 -05:00
|
|
|
Write-Host "==========================================="
|
|
|
|
}
|
|
|
|
Catch {
|
|
|
|
Write-Host "==========================================="
|
2023-10-19 17:12:55 -05:00
|
|
|
Write-Host "-- Winget failed to install ---"
|
2023-05-09 13:14:27 -05:00
|
|
|
Write-Host "==========================================="
|
|
|
|
}
|
|
|
|
$sync.ProcessRunning = $False
|
|
|
|
}
|
|
|
|
}
|