mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-06-11 02:56:32 +00:00
Add confirmation dialogs & warning for Windows Terminal Removal
Removal of this app can cause Win11Debloat to fail, if the script is launched via Windows Terminal
This commit is contained in:
@@ -781,9 +781,9 @@
|
|||||||
{
|
{
|
||||||
"FriendlyName": "Windows Terminal",
|
"FriendlyName": "Windows Terminal",
|
||||||
"AppId": "Microsoft.WindowsTerminal",
|
"AppId": "Microsoft.WindowsTerminal",
|
||||||
"Description": "Default terminal app in windows 11 (Command Prompt, PowerShell, WSL)",
|
"Description": "Default terminal app in windows 11 (Command Prompt, PowerShell, WSL), WARNING: Win11Debloat if it is launched via Windows Terminal.",
|
||||||
"SelectedByDefault": false,
|
"SelectedByDefault": false,
|
||||||
"Recommendation": "optional"
|
"Recommendation": "unsafe"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"FriendlyName": "Xbox TCUI Framework",
|
"FriendlyName": "Xbox TCUI Framework",
|
||||||
|
|||||||
@@ -288,7 +288,7 @@
|
|||||||
"Label": "Remove the apps specified with the 'Apps' parameter",
|
"Label": "Remove the apps specified with the 'Apps' parameter",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -298,7 +298,7 @@
|
|||||||
"Label": "The selection of apps to remove, specified as a comma separated list. Use 'Default' (or omit) to use the default apps list",
|
"Label": "The selection of apps to remove, specified as a comma separated list. Use 'Default' (or omit) to use the default apps list",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -308,7 +308,7 @@
|
|||||||
"Label": "Remove custom selection of apps",
|
"Label": "Remove custom selection of apps",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -318,7 +318,7 @@
|
|||||||
"Label": "Remove the Mail, Calendar, and People apps",
|
"Label": "Remove the Mail, Calendar, and People apps",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -328,7 +328,7 @@
|
|||||||
"Label": "Remove the new Outlook for Windows app",
|
"Label": "Remove the new Outlook for Windows app",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -338,7 +338,7 @@
|
|||||||
"Label": "Remove the Xbox App and Xbox Gamebar",
|
"Label": "Remove the Xbox App and Xbox Gamebar",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
@@ -348,7 +348,7 @@
|
|||||||
"Label": "Remove HP OEM applications",
|
"Label": "Remove HP OEM applications",
|
||||||
"Category": null,
|
"Category": null,
|
||||||
"RegistryKey": null,
|
"RegistryKey": null,
|
||||||
"ApplyText": null,
|
"ApplyText": "Removing selected apps...",
|
||||||
"RegistryUndoKey": null,
|
"RegistryUndoKey": null,
|
||||||
"MinVersion": null,
|
"MinVersion": null,
|
||||||
"MaxVersion": null
|
"MaxVersion": null
|
||||||
|
|||||||
@@ -130,13 +130,9 @@ function Show-AppSelectionWindow {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($selectedApps -contains "Microsoft.WindowsStore" -and -not $Silent) {
|
if (-not (ConfirmUnsafeAppRemoval -SelectedApps $selectedApps -Owner $window)) {
|
||||||
$result = Show-MessageBox -Message 'Are you sure you wish to uninstall the Microsoft Store? This app cannot easily be reinstalled.' -Title 'Are you sure?' -Button 'YesNo' -Icon 'Warning' -Owner $window
|
|
||||||
|
|
||||||
if ($result -eq 'No') {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SaveCustomAppsListToFile -appsList $selectedApps
|
SaveCustomAppsListToFile -appsList $selectedApps
|
||||||
|
|
||||||
|
|||||||
@@ -1773,14 +1773,10 @@ function Show-MainWindow {
|
|||||||
$selectedApps = @($selectedApps | Where-Object { $_ } | Select-Object -Unique)
|
$selectedApps = @($selectedApps | Where-Object { $_ } | Select-Object -Unique)
|
||||||
|
|
||||||
if ($selectedApps.Count -gt 0) {
|
if ($selectedApps.Count -gt 0) {
|
||||||
# Check if Microsoft Store is selected
|
if (-not (ConfirmUnsafeAppRemoval -SelectedApps $selectedApps -Owner $window)) {
|
||||||
if ($selectedApps -contains "Microsoft.WindowsStore") {
|
|
||||||
$result = Show-MessageBox -Message 'Are you sure you wish to uninstall the Microsoft Store? This app cannot easily be reinstalled.' -Title 'Are you sure?' -Button 'YesNo' -Icon 'Warning'
|
|
||||||
|
|
||||||
if ($result -eq 'No') {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
AddParameter 'RemoveApps'
|
AddParameter 'RemoveApps'
|
||||||
AddParameter 'Apps' ($selectedApps -join ',')
|
AddParameter 'Apps' ($selectedApps -join ',')
|
||||||
|
|||||||
34
Scripts/Helpers/ConfirmUnsafeAppRemoval.ps1
Normal file
34
Scripts/Helpers/ConfirmUnsafeAppRemoval.ps1
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Shows confirmation dialogs for apps that require extra caution before removal.
|
||||||
|
# Returns $true if the user confirmed all warnings (or if no warnings were triggered),
|
||||||
|
# $false if the user declined any warning.
|
||||||
|
function ConfirmUnsafeAppRemoval {
|
||||||
|
param (
|
||||||
|
[string[]]$SelectedApps,
|
||||||
|
$Owner = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
# Skip all warnings in Silent mode
|
||||||
|
if ($Silent) {
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Microsoft Store warning
|
||||||
|
if ($SelectedApps -contains "Microsoft.WindowsStore") {
|
||||||
|
$result = Show-MessageBox -Message 'Are you sure that you wish to uninstall the Microsoft Store? This app cannot easily be reinstalled.' -Title 'Are you sure?' -Button 'YesNo' -Icon 'Warning' -Owner $Owner
|
||||||
|
|
||||||
|
if ($result -eq 'No') {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Windows Terminal warning
|
||||||
|
if ($SelectedApps -contains "Microsoft.WindowsTerminal") {
|
||||||
|
$result = Show-MessageBox -Message 'Are you sure that you wish to remove Windows Terminal? Windows Terminal is the default command-line app for Windows. Ensure you are not running Win11Debloat via Windows Terminal before proceeding to avoid a mid-process failure.' -Title 'Are you sure?' -Button 'YesNo' -Icon 'Warning' -Owner $Owner
|
||||||
|
|
||||||
|
if ($result -eq 'No') {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $true
|
||||||
|
}
|
||||||
@@ -351,6 +351,7 @@ if (-not $script:WingetInstalled -and -not $Silent) {
|
|||||||
. "$PSScriptRoot/Scripts/Helpers/RegistryPathHelpers.ps1"
|
. "$PSScriptRoot/Scripts/Helpers/RegistryPathHelpers.ps1"
|
||||||
. "$PSScriptRoot/Scripts/Helpers/ApplyRegistryRegFile.ps1"
|
. "$PSScriptRoot/Scripts/Helpers/ApplyRegistryRegFile.ps1"
|
||||||
. "$PSScriptRoot/Scripts/Helpers/TestIfUserIsLoggedIn.ps1"
|
. "$PSScriptRoot/Scripts/Helpers/TestIfUserIsLoggedIn.ps1"
|
||||||
|
. "$PSScriptRoot/Scripts/Helpers/ConfirmUnsafeAppRemoval.ps1"
|
||||||
|
|
||||||
# Threading functions
|
# Threading functions
|
||||||
. "$PSScriptRoot/Scripts/Threading/DoEvents.ps1"
|
. "$PSScriptRoot/Scripts/Threading/DoEvents.ps1"
|
||||||
|
|||||||
Reference in New Issue
Block a user