From a05465356e003edf8e96dc855ac9d64a9751bc34 Mon Sep 17 00:00:00 2001
From: Raphire <9938813+Raphire@users.noreply.github.com>
Date: Mon, 4 Mar 2024 12:56:12 +0100
Subject: [PATCH] Changes to application selector and more: * Added option to
only show installed apps in application selector * App removal loading bars
are now hidden so it doesn't overwrite Win11Debloat's output * Changed some
user input checks to allow user to continue or quit * Cleaned up and improved
selectionBox loading * Edge added to appslist, but not removed by default
---
Appslist.txt | 1 +
Menus/DefaultSettings | 2 +-
Menus/Info | 6 +-
README.md | 9 +-
Win11Debloat.ps1 | 238 ++++++++++++++++++++++++------------------
5 files changed, 146 insertions(+), 110 deletions(-)
diff --git a/Appslist.txt b/Appslist.txt
index af06fff..60424db 100644
--- a/Appslist.txt
+++ b/Appslist.txt
@@ -95,6 +95,7 @@
# simply remove the # character in front of the specific app.
#
#*Microsoft.GetHelp* # Required for some Windows 11 Troubleshooters
+#*Microsoft.MicrosoftEdge.Stable* # Edge browser
#*Microsoft.MSPaint* # Paint 3D
#*Microsoft.Paint* # Classic Paint
#*Microsoft.ScreenSketch* # Snipping Tool
diff --git a/Menus/DefaultSettings b/Menus/DefaultSettings
index e7eca22..dfa219f 100644
--- a/Menus/DefaultSettings
+++ b/Menus/DefaultSettings
@@ -2,7 +2,7 @@
Win11Debloat - Setup
-------------------------------------------------------------------------------------------
Win11Debloat will make the following changes:
-- Remove bloatware apps, the list can be found in the 'Appslist.txt' file.
+- Remove the default selection of bloatware apps, the list can be found in the 'Appslist.txt' file.
- Disable telemetry, diagnostic data, app-launch tracking & targeted ads.
- Disable & remove bing search & cortana in Windows search.
- Disable tips & tricks on the lockscreen. (This may change your lockscreen wallpaper)
diff --git a/Menus/Info b/Menus/Info
index 5acd06d..9bd9be5 100644
--- a/Menus/Info
+++ b/Menus/Info
@@ -9,7 +9,7 @@ through all the settings yourself, or removing apps one by one!
-------------------------------------------------------------------------------------------
Using the default configuration the script will
-------------------------------------------------------------------------------------------
-- Remove all bloatware apps, the list can be found in the 'Appslist.txt' file.
+- Remove the default selection of bloatware apps, the list can be found in the 'Appslist.txt' file.
- Disable telemetry, diagnostic data, app-launch tracking & targeted ads.
- Disable & remove bing search & cortana in Windows search.
- Disable tips, tricks, suggestions and ads in start, settings, notifications, windows explorer, and on the lockscreen.
@@ -22,9 +22,7 @@ through all the settings yourself, or removing apps one by one!
-------------------------------------------------------------------------------------------
Using the custom mode you can
-------------------------------------------------------------------------------------------
-- Remove bloatware apps, check the full list in the 'Appslist.txt' file.
-- Remove gaming-related apps, check the full list in the 'GamingAppslist.txt' file.
-- Remove Mail & Calendar, People or new Outlook for Windows apps.
+- Remove bloatware apps, with the option to select exactly what apps to remove or keep.
- Remove all pinned apps from the start menu. NOTE: This applies to all existing and new users. (Windows 11 build 22621+)
- Disable telemetry, diagnostic data, app-launch tracking & targeted ads.
- Disable & remove bing search & cortana in Windows search.
diff --git a/README.md b/README.md
index 4eddb33..990952f 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ You can pick and choose exactly which modifications you want the script to make,
### Default Settings
-- Remove all bloatware apps from [this list](#apps-that-are-removed).
+- Remove the default selection of bloatware apps from [this list](#apps-that-are-removed).
- Disable telemetry, diagnostic data, app-launch tracking & targeted ads.
- Disable & remove bing search & cortana in Windows search.
- Disable tips, tricks, suggestions and ads in start, settings, notifications, Windows explorer, and on the lockscreen.
@@ -24,7 +24,7 @@ You can pick and choose exactly which modifications you want the script to make,
### All Features
-- Remove all bloatware apps from [this list](#apps-that-are-removed) or optionally select exactly which apps to remove or keep.
+- Remove bloatware apps, with the option to select exactly what apps to remove or keep.
- Remove all pinned apps from the start menu. NOTE: This applies to all existing and new users. (Windows 11 only)
- Disable telemetry, diagnostic data, app-launch tracking & targeted ads.
- Disable & remove bing search & cortana in Windows search.
@@ -47,7 +47,7 @@ You can pick and choose exactly which modifications you want the script to make,
> [!TIP]
> In 'custom mode' you can specify exactly which apps you like to remove and which you want to keep!
-### Apps that ARE removed
+### Apps that ARE removed by default
Click to expand
@@ -147,7 +147,7 @@ You can pick and choose exactly which modifications you want the script to make,
-### Apps that are NOT removed
+### Apps that are NOT removed by default
Click to expand
@@ -155,6 +155,7 @@ You can pick and choose exactly which modifications you want the script to make,
General apps that are not removed by default:
- Microsoft.GetHelp (Required for some Windows 11 Troubleshooters)
+ - Microsoft.MicrosoftEdge.Stable (Edge browser)
- Microsoft.MSPaint (Paint 3D)
- Microsoft.OutlookForWindows* (New mail app)
- Microsoft.Paint (Classic Paint)
diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1
index bf18eb4..f9a528b 100644
--- a/Win11Debloat.ps1
+++ b/Win11Debloat.ps1
@@ -59,7 +59,9 @@ function ShowAppSelectionForm {
$button1 = New-Object System.Windows.Forms.Button
$button2 = New-Object System.Windows.Forms.Button
$selectionBox = New-Object System.Windows.Forms.CheckedListBox
- $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
+ $loadingLabel = New-Object System.Windows.Forms.Label
+ $onlyInstalledCheckBox = New-Object System.Windows.Forms.CheckBox
+ $initialFormWindowState = New-Object System.Windows.Forms.FormWindowState
# saveButton eventHandler
$handler_saveButton_Click=
@@ -82,23 +84,78 @@ function ShowAppSelectionForm {
$form.Close()
}
- # Correct the initial state of the form to prevent the .Net maximized form issue
- $OnLoadForm_StateCorrection=
+ $load_Apps=
{
- $form.WindowState = $InitialFormWindowState
+ # Correct the initial state of the form to prevent the .Net maximized form issue
+ $form.WindowState = $initialFormWindowState
+
+ # Show loading indicator
+ $loadingLabel.Visible = $true
+ $form.Refresh()
+
+ # Clear selectionBox before adding any new items
+ $selectionBox.Items.Clear()
+
+ # Set filePath where Appslist can be found
+ $appsFile = "$PSScriptRoot/Appslist.txt"
+
+ # Go through appslist and add items one by one to the selectionBox
+ Foreach ($app in (Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^\s*$' } )) {
+ $appChecked = $true
+
+ # Remove first # if it exists and set AppChecked to false
+ if ($app.StartsWith('#')) {
+ $app = $app.TrimStart("#")
+ $appChecked = $false
+ }
+ # Remove any comments from the Appname
+ if (-not ($app.IndexOf('#') -eq -1)) {
+ $app = $app.Substring(0, $app.IndexOf('#'))
+ }
+ # Remove any remaining spaces from the Appname
+ if (-not ($app.IndexOf(' ') -eq -1)) {
+ $app = $app.Substring(0, $app.IndexOf(' '))
+ }
+
+ $appString = $app.Trim('*')
+
+ # Make sure appString is not empty
+ if ($appString.length -gt 0) {
+ if($onlyInstalledCheckBox.Checked) {
+ # onlyInstalledCheckBox is checked, check if app is installed before adding to selectionBox
+ $installed = Get-AppxPackage -Name $app
+
+ if($installed.length -eq 0) {
+ # App is not installed, continue to next item without adding this app to the selectionBox
+ continue
+ }
+ }
+
+ # Add the app to the selectionBox and set it's checked status
+ $selectionBox.Items.Add($appString, $appChecked) | Out-Null
+ }
+ }
+
+ # Hide loading indicator
+ $loadingLabel.Visible = $false
+
+ # Sort selectionBox alphabetically
+ $selectionBox.Sorted = $true;
}
$form.Text = "Win11Debloat Application Selection"
$form.Name = "appSelectionForm"
$form.DataBindings.DefaultDataSourceUpdateMode = 0
- $form.ClientSize = New-Object System.Drawing.Size(400,486)
+ $form.ClientSize = New-Object System.Drawing.Size(400,485)
+ $form.FormBorderStyle = 'FixedDialog'
+ $form.MaximizeBox = $false
$button1.TabIndex = 4
$button1.Name = "saveButton"
$button1.DialogResult = [System.Windows.Forms.DialogResult]::OK
$button1.UseVisualStyleBackColor = $True
$button1.Text = "Save"
- $button1.Location = New-Object System.Drawing.Point(27,450)
+ $button1.Location = New-Object System.Drawing.Point(27,454)
$button1.Size = New-Object System.Drawing.Size(75,23)
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$button1.add_Click($handler_saveButton_Click)
@@ -110,85 +167,49 @@ function ShowAppSelectionForm {
$button2.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$button2.UseVisualStyleBackColor = $True
$button2.Text = "Cancel"
- $button2.Location = New-Object System.Drawing.Point(129,450)
+ $button2.Location = New-Object System.Drawing.Point(129,454)
$button2.Size = New-Object System.Drawing.Size(75,23)
$button2.DataBindings.DefaultDataSourceUpdateMode = 0
$button2.add_Click($handler_cancelButton_Click)
$form.Controls.Add($button2)
- $label.Location = New-Object System.Drawing.Point(13,0)
+ $label.Location = New-Object System.Drawing.Point(13,5)
$label.Size = New-Object System.Drawing.Size(400,20)
- $label.Text = 'Check all apps that you wish to remove'
+ $label.Text = 'Check apps that you wish to remove, uncheck apps that you wish to keep'
$form.Controls.Add($label)
+ $loadingLabel.Location = New-Object System.Drawing.Point(16,28)
+ $loadingLabel.Size = New-Object System.Drawing.Size(200,418)
+ $loadingLabel.Text = 'Loading...'
+ $loadingLabel.BackColor = "White"
+ $loadingLabel.Visible = $false
+
+ $form.Controls.Add($loadingLabel)
+
+ $onlyInstalledCheckBox.TabIndex = 6
+ $onlyInstalledCheckBox.Location = New-Object System.Drawing.Point(230,456)
+ $onlyInstalledCheckBox.Size = New-Object System.Drawing.Size(150,20)
+ $onlyInstalledCheckBox.Text = 'Only show installed apps'
+ $onlyInstalledCheckBox.add_CheckedChanged($load_Apps)
+
+ $form.Controls.Add($onlyInstalledCheckBox)
+
$selectionBox.FormattingEnabled = $True
$selectionBox.DataBindings.DefaultDataSourceUpdateMode = 0
$selectionBox.Name = "selectionBox"
- $selectionBox.Location = New-Object System.Drawing.Point(13,20)
+ $selectionBox.Location = New-Object System.Drawing.Point(13,25)
$selectionBox.Size = New-Object System.Drawing.Size(374,424)
$selectionBox.TabIndex = 3
$form.Controls.Add($selectionBox)
- # Keep track of number of checkboxes
- $selectionBoxItemCounter = 0
-
- $appsFile = "$PSScriptRoot/Appslist.txt"
-
- # Go through appslist and add all items that should be checked by default
- Foreach ($app in (Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } )) {
- # Remove any comments from the Appname
- if (-not ($app.IndexOf('#') -eq -1)) {
- $app = $app.Substring(0, $app.IndexOf('#'))
- }
- # Remove any remaining spaces from the Appname
- if (-not ($app.IndexOf(' ') -eq -1)) {
- $app = $app.Substring(0, $app.IndexOf(' '))
- }
-
- $appString = $app.Trim('*')
-
- if ($appString.length -gt 0) {
- $selectionBox.Items.Add($appString) | Out-Null
- $selectionBox.SetItemChecked($selectionBoxItemCounter, $true);
- $selectionBoxItemCounter++
- }
- }
-
- # Go through appslist and add all items that should NOT be checked by default
- Foreach ($app in (Get-Content -Path $appsFile | Where-Object { $_ -match '^#.*' -and $_ -notmatch '^\s*$' } )) {
- # Remove first #
- if (-not ($app.IndexOf('#') -eq -1)) {
- $app = $app.TrimStart("#")
- }
- # Remove any comments from the Appname
- if (-not ($app.IndexOf('#') -eq -1)) {
- $app = $app.Substring(0, $app.IndexOf('#'))
- }
- # Remove any remaining spaces from the Appname
- if (-not ($app.IndexOf(' ') -eq -1)) {
- $app = $app.Substring(0, $app.IndexOf(' '))
- }
-
- $appString = $app.Trim('*')
-
- if ($appString.length -gt 0) {
- $selectionBox.Items.Add($appString) | Out-Null
- $selectionBox.SetItemChecked($selectionBoxItemCounter, $false);
- $selectionBoxItemCounter++
- }
- }
-
- # Sort selectionBox alphabetically
- $selectionBox.Sorted = $true;
-
# Save the initial state of the form
- $InitialFormWindowState = $form.WindowState
+ $initialFormWindowState = $form.WindowState
- # Init the OnLoad event to correct the initial state of the form
- $form.add_Load($OnLoadForm_StateCorrection)
+ # Load apps into selectionBox
+ $form.add_Load($load_Apps)
# Focus selectionBox when form opens
$form.Add_Shown({$form.Activate(); $selectionBox.Focus()})
@@ -242,8 +263,9 @@ function RemoveSpecificApps {
)
Foreach ($app in $appsList) {
- $appString = $app.Trim('*')
- Write-Output "Attempting to remove $appString..."
+ Write-Output "Attempting to remove $app..."
+
+ $app = '*' + $app + '*'
# Remove installed app for all existing users
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
@@ -388,6 +410,9 @@ function PrintFromFile {
}
+# Hide progress bars for app removal, as they block Win11Debloat's output
+$ProgressPreference = 'SilentlyContinue'
+
$global:Params = $PSBoundParameters;
$global:FirstSelection = $true
$SPParams = 'WhatIf', 'Confirm', 'Verbose', 'Silent'
@@ -443,8 +468,8 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP
# Get & print default settings info from file
PrintFromFile "$PSScriptRoot/Menus/DefaultSettings"
- Write-Output "Press any key to start..."
- $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
+ Write-Output "Press enter to execute the script or press CTRL+C to quit..."
+ Read-Host | Out-Null
}
elseif (($Mode -eq '3')) {
if (Test-Path "$PSScriptRoot/LastSettings") {
@@ -453,24 +478,39 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP
Write-Output "Win11Debloat will make the following changes:"
# Get & print default settings info from file
- Foreach ($Line in (Get-Content -Path "$PSScriptRoot/LastSettings" )) {
+ Foreach ($line in (Get-Content -Path "$PSScriptRoot/LastSettings" )) {
# Remove any spaces before and after the Appname
- $Line = $Line.Trim()
+ $line = $line.Trim()
# Check if line has # char, show description, add parameter
- if (-not ($Line.IndexOf('#') -eq -1)) {
- Write-Output $Line.Substring(($Line.IndexOf('#') + 1), ($Line.Length - $Line.IndexOf('#') - 1))
- $Line = $Line.Substring(0, $Line.IndexOf('#'))
+ if (-not ($line.IndexOf('#') -eq -1)) {
+ Write-Output $line.Substring(($line.IndexOf('#') + 1), ($line.Length - $line.IndexOf('#') - 1))
+ $paramName = $line.Substring(0, $line.IndexOf('#'))
+
+ # Print list of apps slated for removal if paramName is RemoveAppsCustom and CustomAppsList exists
+ if(($paramName -eq "RemoveAppsCustom") -and (Test-Path "$PSScriptRoot/CustomAppsList")) {
+ $appsList = @()
+
+ # Get apps list from file
+ Foreach ($app in (Get-Content -Path "$PSScriptRoot/CustomAppsList" )) {
+ # Remove any spaces before and after the app name
+ $app = $app.Trim()
+
+ $appsList += $app
+ }
+
+ Write-Host $appsList -ForegroundColor Gray
+ }
if(-not $global:Params.ContainsKey($ParameterName)){
- $global:Params.Add($Line, $true)
+ $global:Params.Add($paramName, $true)
}
}
}
Write-Output ""
- Write-Output "Press any key to start..."
- $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
+ Write-Output "Press enter to execute the script or press CTRL+C to quit..."
+ Read-Host | Out-Null
}
}
else {
@@ -550,7 +590,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP
'3' {
Write-Output "$($global:SelectedApps.Count) apps have been selected for removal"
- AddParameter 'RemoveAppsCustom' 'Remove custom selection of apps'
+ AddParameter 'RemoveAppsCustom' "Remove $($global:SelectedApps.Count) apps:"
}
}
@@ -740,8 +780,8 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP
Write-Output ""
Write-Output ""
Write-Output ""
- Write-Output "Press any key to confirm your choices and execute the script..."
- $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
+ Write-Output "Press enter to confirm your choices and execute the script or press CTRL+C to quit..."
+ Read-Host | Out-Null
}
PrintHeader 'Custom Configuration'
@@ -778,23 +818,19 @@ else {
continue
}
'RemoveAppsCustom' {
- if ($global:SelectedApps.Count -gt 0) {
- Write-Output "> Removing custom selection of $($global:SelectedApps.Count) apps..."
- RemoveSpecificApps $global:SelectedApps
- }
- elseif (Test-Path "$PSScriptRoot/CustomAppsList") {
- $AppsList = @()
+ if (Test-Path "$PSScriptRoot/CustomAppsList") {
+ $appsList = @()
# Get apps list from file
- Foreach ($App in (Get-Content -Path "$PSScriptRoot/CustomAppsList" )) {
+ Foreach ($app in (Get-Content -Path "$PSScriptRoot/CustomAppsList" )) {
# Remove any spaces before and after the app name
- $App = $App.Trim()
+ $app = $app.Trim()
- $AppsList += $App
+ $appsList += $app
}
- Write-Output "> Removing custom selection of $($AppsList.Count) apps..."
- RemoveSpecificApps $AppsList
+ Write-Output "> Removing $($appsList.Count) apps..."
+ RemoveSpecificApps $appsList
}
else {
Write-Host "> Unable to find CustomAppsList file, no apps have been removed!" -ForegroundColor Red
@@ -806,8 +842,8 @@ else {
'RemoveCommApps' {
Write-Output "> Removing Mail, Calendar and People apps..."
- $AppsList = '*Microsoft.windowscommunicationsapps*', '*Microsoft.People*'
- RemoveSpecificApps $AppsList
+ $appsList = 'Microsoft.windowscommunicationsapps', 'Microsoft.People'
+ RemoveSpecificApps $appsList
Write-Output ""
continue
@@ -815,8 +851,8 @@ else {
'RemoveW11Outlook' {
Write-Output "> Removing new Outlook for Windows app..."
- $AppsList = '*Microsoft.OutlookForWindows*'
- RemoveSpecificApps $AppsList
+ $appsList = 'Microsoft.OutlookForWindows'
+ RemoveSpecificApps $appsList
Write-Output ""
continue
@@ -824,8 +860,8 @@ else {
'RemoveDevApps' {
Write-Output "> Removing developer-related related apps..."
- $AppsList = '*Microsoft.PowerAutomateDesktop*', '*Microsoft.RemoteDesktop*', '*Windows.DevHome*'
- RemoveSpecificApps $AppsList
+ $appsList = 'Microsoft.PowerAutomateDesktop', 'Microsoft.RemoteDesktop', 'Windows.DevHome'
+ RemoveSpecificApps $appsList
Write-Output ""
@@ -834,8 +870,8 @@ else {
'RemoveGamingApps' {
Write-Output "> Removing gaming related apps..."
- $AppsList = '*Microsoft.GamingApp*', '*Microsoft.XboxGameOverlay*', '*Microsoft.XboxGamingOverlay*'
- RemoveSpecificApps $AppsList
+ $appsList = 'Microsoft.GamingApp', 'Microsoft.XboxGameOverlay', 'Microsoft.XboxGamingOverlay'
+ RemoveSpecificApps $appsList
Write-Output ""
@@ -853,8 +889,8 @@ else {
RegImport "> Disabling bing search, bing AI & cortana in Windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Cortana_In_Search.reg
# Also remove the app package for bing search
- $AppsList = '*Microsoft.BingSearch*'
- RemoveSpecificApps $AppsList
+ $appsList = 'Microsoft.BingSearch'
+ RemoveSpecificApps $appsList
Write-Output ""