2022-10-04 21:10:29 +02:00
# Requires -RunAsAdministrator
2020-11-07 02:57:38 +01:00
[ CmdletBinding ( SupportsShouldProcess ) ]
2024-01-31 22:19:50 +01:00
param (
2024-03-11 23:38:19 +01:00
[ switch ] $Silent ,
2024-06-27 23:08:43 +02:00
[ switch ] $Sysprep ,
2025-05-10 13:02:48 +02:00
[ string ] $LogPath ,
2025-03-05 23:39:29 +01:00
[ string ] $User ,
2025-05-03 17:55:31 +02:00
[ switch ] $CreateRestorePoint ,
2025-04-19 15:16:47 +02:00
[ switch ] $RunAppsListGenerator , [ switch ] $RunAppConfigurator ,
2024-03-11 23:38:19 +01:00
[ switch ] $RunDefaults , [ switch ] $RunWin11Defaults ,
2025-01-09 21:33:28 +01:00
[ switch ] $RunSavedSettings ,
2024-03-11 23:38:19 +01:00
[ switch ] $RemoveApps ,
[ switch ] $RemoveAppsCustom ,
[ switch ] $RemoveGamingApps ,
[ switch ] $RemoveCommApps ,
[ switch ] $RemoveDevApps ,
2025-05-04 12:27:19 -04:00
[ switch ] $RemoveHPApps ,
2024-03-11 23:38:19 +01:00
[ switch ] $RemoveW11Outlook ,
2024-07-02 18:51:00 +02:00
[ switch ] $ForceRemoveEdge ,
2024-05-24 14:13:15 +02:00
[ switch ] $DisableDVR ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableTelemetry ,
2025-05-01 22:32:41 +01:00
[ switch ] $DisableFastStartup ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableBingSearches , [ switch ] $DisableBing ,
2024-12-26 19:06:49 +01:00
[ switch ] $DisableDesktopSpotlight ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableLockscrTips , [ switch ] $DisableLockscreenTips ,
[ switch ] $DisableWindowsSuggestions , [ switch ] $DisableSuggestions ,
2025-05-20 21:55:38 +02:00
[ switch ] $DisableSettings365Ads ,
2025-05-20 21:56:04 +02:00
[ switch ] $DisableSettingsHome ,
2024-03-11 23:38:19 +01:00
[ switch ] $ShowHiddenFolders ,
[ switch ] $ShowKnownFileExt ,
[ switch ] $HideDupliDrive ,
[ switch ] $TaskbarAlignLeft ,
[ switch ] $HideSearchTb , [ switch ] $ShowSearchIconTb , [ switch ] $ShowSearchLabelTb , [ switch ] $ShowSearchBoxTb ,
[ switch ] $HideTaskview ,
2025-02-03 21:27:46 +01:00
[ switch ] $DisableStartRecommended ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableCopilot ,
2024-06-05 09:17:24 +02:00
[ switch ] $DisableRecall ,
2025-02-13 21:08:47 +01:00
[ switch ] $DisableWidgets , [ switch ] $HideWidgets ,
[ switch ] $DisableChat , [ switch ] $HideChat ,
2025-04-16 12:31:18 +02:00
[ switch ] $EnableEndTask ,
2024-03-11 23:38:19 +01:00
[ switch ] $ClearStart ,
2025-05-19 00:01:49 +02:00
[ string ] $ReplaceStart ,
2024-06-27 23:08:43 +02:00
[ switch ] $ClearStartAllUsers ,
2025-05-19 00:01:49 +02:00
[ string ] $ReplaceStartAllUsers ,
2024-03-11 23:38:19 +01:00
[ switch ] $RevertContextMenu ,
2025-02-13 21:08:47 +01:00
[ switch ] $DisableMouseAcceleration ,
2025-04-16 12:56:37 +02:00
[ switch ] $DisableStickyKeys ,
2024-09-04 17:46:41 +02:00
[ switch ] $HideHome ,
2024-06-29 16:18:23 +02:00
[ switch ] $HideGallery ,
2024-10-27 19:28:43 +01:00
[ switch ] $ExplorerToHome ,
[ switch ] $ExplorerToThisPC ,
[ switch ] $ExplorerToDownloads ,
[ switch ] $ExplorerToOneDrive ,
2024-03-11 23:38:19 +01:00
[ switch ] $DisableOnedrive , [ switch ] $HideOnedrive ,
[ switch ] $Disable3dObjects , [ switch ] $Hide3dObjects ,
[ switch ] $DisableMusic , [ switch ] $HideMusic ,
[ switch ] $DisableIncludeInLibrary , [ switch ] $HideIncludeInLibrary ,
[ switch ] $DisableGiveAccessTo , [ switch ] $HideGiveAccessTo ,
[ switch ] $DisableShare , [ switch ] $HideShare
2020-11-07 02:57:38 +01:00
)
2023-08-03 22:24:27 +02:00
2025-02-13 21:08:47 +01:00
# Show error if current powershell environment is limited by security policies
2024-06-26 20:27:25 +02:00
if ( $ExecutionContext . SessionState . LanguageMode -ne " FullLanguage " ) {
2024-07-02 18:51:00 +02:00
Write-Host " Error: Win11Debloat is unable to run on your system, powershell execution is restricted by security policies " -ForegroundColor Red
2025-05-10 16:42:03 +02:00
AwaitKeyToExit
2024-06-26 20:27:25 +02:00
}
2025-05-10 13:02:48 +02:00
# Log script output to 'Win11Debloat.log' at the specified path
if ( $LogPath -and ( Test-Path $LogPath ) ) {
Start-Transcript -Path " $LogPath /Win11Debloat.log " -Append -IncludeInvocationHeader -Force | Out-Null
}
else {
Start-Transcript -Path " $PSScriptRoot /Win11Debloat.log " -Append -IncludeInvocationHeader -Force | Out-Null
}
2024-06-26 20:27:25 +02:00
2024-03-04 00:10:24 +01:00
# Shows application selection form that allows the user to select what apps they want to remove or keep
function ShowAppSelectionForm {
[ reflection.assembly ] :: loadwithpartialname ( " System.Windows.Forms " ) | Out-Null
[ reflection.assembly ] :: loadwithpartialname ( " System.Drawing " ) | Out-Null
# Initialise form objects
$form = New-Object System . Windows . Forms . Form
$label = New-Object System . Windows . Forms . Label
$button1 = New-Object System . Windows . Forms . Button
$button2 = New-Object System . Windows . Forms . Button
$selectionBox = New-Object System . Windows . Forms . CheckedListBox
2024-03-04 12:56:12 +01:00
$loadingLabel = New-Object System . Windows . Forms . Label
$onlyInstalledCheckBox = New-Object System . Windows . Forms . CheckBox
2024-04-05 23:35:10 +02:00
$checkUncheckCheckBox = New-Object System . Windows . Forms . CheckBox
2024-03-04 12:56:12 +01:00
$initialFormWindowState = New-Object System . Windows . Forms . FormWindowState
2024-03-04 00:10:24 +01:00
2025-05-10 13:02:48 +02:00
$script:selectionBoxIndex = -1
2024-04-05 23:35:10 +02:00
2024-03-04 00:10:24 +01:00
# saveButton eventHandler
$handler_saveButton_Click =
{
2024-09-17 15:06:18 +02:00
if ( $selectionBox . CheckedItems -contains " Microsoft.WindowsStore " -and -not $Silent ) {
$warningSelection = [ System.Windows.Forms.Messagebox ] :: Show ( 'Are you sure you wish to uninstall the Microsoft Store? This app cannot easily be reinstalled.' , 'Are you sure?' , 'YesNo' , 'Warning' )
if ( $warningSelection -eq 'No' ) {
return
}
}
2025-05-10 13:02:48 +02:00
$script:SelectedApps = $selectionBox . CheckedItems
2024-03-04 00:10:24 +01:00
# Create file that stores selected apps if it doesn't exist
2025-05-07 15:51:01 +02:00
if ( -not ( Test-Path " $PSScriptRoot /CustomAppsList " ) ) {
2024-03-04 00:10:24 +01:00
$null = New-Item " $PSScriptRoot /CustomAppsList "
}
2025-05-10 13:02:48 +02:00
Set-Content -Path " $PSScriptRoot /CustomAppsList " -Value $script:SelectedApps
2024-03-04 00:10:24 +01:00
2024-09-17 15:06:18 +02:00
$form . DialogResult = [ System.Windows.Forms.DialogResult ] :: OK
2024-03-04 00:10:24 +01:00
$form . Close ( )
}
# cancelButton eventHandler
$handler_cancelButton_Click =
{
$form . Close ( )
}
2024-04-05 23:35:10 +02:00
$selectionBox_SelectedIndexChanged =
{
2025-05-10 13:02:48 +02:00
$script:selectionBoxIndex = $selectionBox . SelectedIndex
2024-04-05 23:35:10 +02:00
}
$selectionBox_MouseDown =
{
if ( $_ . Button -eq [ System.Windows.Forms.MouseButtons ] :: Left ) {
2024-08-17 00:08:09 +02:00
if ( [ System.Windows.Forms.Control ] :: ModifierKeys -eq [ System.Windows.Forms.Keys ] :: Shift ) {
2025-05-10 13:02:48 +02:00
if ( $script:selectionBoxIndex -ne -1 ) {
$topIndex = $script:selectionBoxIndex
2024-04-05 23:35:10 +02:00
if ( $selectionBox . SelectedIndex -gt $topIndex ) {
2025-05-16 18:26:06 +02:00
for ( ( $i = ( $topIndex ) ) ; $i -le $selectionBox . SelectedIndex ; $i + + ) {
2024-04-05 23:35:10 +02:00
$selectionBox . SetItemChecked ( $i , $selectionBox . GetItemChecked ( $topIndex ) )
}
}
elseif ( $topIndex -gt $selectionBox . SelectedIndex ) {
2025-05-16 18:26:06 +02:00
for ( ( $i = ( $selectionBox . SelectedIndex ) ) ; $i -le $topIndex ; $i + + ) {
2024-04-05 23:35:10 +02:00
$selectionBox . SetItemChecked ( $i , $selectionBox . GetItemChecked ( $topIndex ) )
}
}
}
}
2025-05-10 13:02:48 +02:00
elseif ( $script:selectionBoxIndex -ne $selectionBox . SelectedIndex ) {
2024-04-05 23:35:10 +02:00
$selectionBox . SetItemChecked ( $selectionBox . SelectedIndex , -not $selectionBox . GetItemChecked ( $selectionBox . SelectedIndex ) )
}
}
}
$check_All =
{
2025-05-16 18:26:06 +02:00
for ( ( $i = 0 ) ; $i -lt $selectionBox . Items . Count ; $i + + ) {
2024-04-05 23:35:10 +02:00
$selectionBox . SetItemChecked ( $i , $checkUncheckCheckBox . Checked )
}
}
2024-03-04 12:56:12 +01:00
$load_Apps =
2024-03-04 00:10:24 +01:00
{
2024-03-04 12:56:12 +01:00
# Correct the initial state of the form to prevent the .Net maximized form issue
$form . WindowState = $initialFormWindowState
2024-04-05 23:35:10 +02:00
# Reset state to default before loading appslist again
2025-05-10 13:02:48 +02:00
$script:selectionBoxIndex = -1
2024-04-05 23:35:10 +02:00
$checkUncheckCheckBox . Checked = $False
2024-03-04 12:56:12 +01:00
# 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 "
2024-03-29 16:56:29 +01:00
$listOfApps = " "
2025-05-10 13:02:48 +02:00
if ( $onlyInstalledCheckBox . Checked -and ( $script:wingetInstalled -eq $true ) ) {
2024-04-01 14:07:59 +02:00
# Attempt to get a list of installed apps via winget, times out after 10 seconds
$job = Start-Job { return winget list - -accept -source -agreements - -disable -interactivity }
$jobDone = $job | Wait-Job -TimeOut 10
if ( -not $jobDone ) {
# Show error that the script was unable to get list of apps from winget
2024-09-17 15:06:18 +02:00
[ System.Windows.MessageBox ] :: Show ( 'Unable to load list of installed apps via winget, some apps may not be displayed in the list.' , 'Error' , 'Ok' , 'Error' )
2024-04-01 14:07:59 +02:00
}
else {
# Add output of job (list of apps) to $listOfApps
$listOfApps = Receive-Job -Job $job
}
2024-03-29 16:56:29 +01:00
}
2024-03-04 12:56:12 +01:00
# Go through appslist and add items one by one to the selectionBox
2024-08-19 21:27:53 +02:00
Foreach ( $app in ( Get-Content -Path $appsFile | Where-Object { $_ -notmatch '^\s*$' -and $_ -notmatch '^# .*' -and $_ -notmatch '^# -* #' } ) ) {
2024-03-04 12:56:12 +01:00
$appChecked = $true
2024-08-19 21:27:53 +02:00
# Remove first # if it exists and set appChecked to false
2024-03-04 12:56:12 +01:00
if ( $app . StartsWith ( '#' ) ) {
$app = $app . TrimStart ( " # " )
$appChecked = $false
}
2024-08-19 21:27:53 +02:00
2024-03-04 12:56:12 +01:00
# Remove any comments from the Appname
if ( -not ( $app . IndexOf ( '#' ) -eq -1 ) ) {
$app = $app . Substring ( 0 , $app . IndexOf ( '#' ) )
}
2024-08-19 21:27:53 +02:00
# Remove leading and trailing spaces and `*` characters from Appname
$app = $app . Trim ( )
2024-03-04 12:56:12 +01:00
$appString = $app . Trim ( '*' )
# Make sure appString is not empty
if ( $appString . length -gt 0 ) {
2024-03-29 16:56:29 +01:00
if ( $onlyInstalledCheckBox . Checked ) {
# onlyInstalledCheckBox is checked, check if app is installed before adding it to selectionBox
2024-08-19 21:27:53 +02:00
if ( -not ( $listOfApps -like ( " * $appString * " ) ) -and -not ( Get-AppxPackage -Name $app ) ) {
2024-07-02 18:51:00 +02:00
# App is not installed, continue with next item
continue
2024-03-29 16:56:29 +01:00
}
2024-07-02 18:51:00 +02:00
if ( ( $appString -eq " Microsoft.Edge " ) -and -not ( $listOfApps -like " * Microsoft.Edge * " ) ) {
# App is not installed, continue with next item
2024-03-04 12:56:12 +01:00
continue
}
}
# Add the app to the selectionBox and set it's checked status
$selectionBox . Items . Add ( $appString , $appChecked ) | Out-Null
}
}
# Hide loading indicator
2024-04-05 23:35:10 +02:00
$loadingLabel . Visible = $False
2024-03-04 12:56:12 +01:00
# Sort selectionBox alphabetically
2024-04-05 23:35:10 +02:00
$selectionBox . Sorted = $True
2024-03-04 00:10:24 +01:00
}
$form . Text = " Win11Debloat Application Selection "
$form . Name = " appSelectionForm "
$form . DataBindings . DefaultDataSourceUpdateMode = 0
2024-04-05 23:35:10 +02:00
$form . ClientSize = New-Object System . Drawing . Size ( 400 , 502 )
2024-03-04 12:56:12 +01:00
$form . FormBorderStyle = 'FixedDialog'
2024-04-05 23:35:10 +02:00
$form . MaximizeBox = $False
2024-03-04 00:10:24 +01:00
$button1 . TabIndex = 4
$button1 . Name = " saveButton "
$button1 . UseVisualStyleBackColor = $True
2024-03-29 16:56:29 +01:00
$button1 . Text = " Confirm "
2024-04-05 23:35:10 +02:00
$button1 . Location = New-Object System . Drawing . Point ( 27 , 472 )
2024-03-04 00:10:24 +01:00
$button1 . Size = New-Object System . Drawing . Size ( 75 , 23 )
$button1 . DataBindings . DefaultDataSourceUpdateMode = 0
$button1 . add_Click ( $handler_saveButton_Click )
$form . Controls . Add ( $button1 )
$button2 . TabIndex = 5
$button2 . Name = " cancelButton "
$button2 . DialogResult = [ System.Windows.Forms.DialogResult ] :: Cancel
$button2 . UseVisualStyleBackColor = $True
$button2 . Text = " Cancel "
2024-04-05 23:35:10 +02:00
$button2 . Location = New-Object System . Drawing . Point ( 129 , 472 )
2024-03-04 00:10:24 +01:00
$button2 . Size = New-Object System . Drawing . Size ( 75 , 23 )
$button2 . DataBindings . DefaultDataSourceUpdateMode = 0
$button2 . add_Click ( $handler_cancelButton_Click )
$form . Controls . Add ( $button2 )
2024-03-04 12:56:12 +01:00
$label . Location = New-Object System . Drawing . Point ( 13 , 5 )
2024-04-05 23:35:10 +02:00
$label . Size = New-Object System . Drawing . Size ( 400 , 14 )
$Label . Font = 'Microsoft Sans Serif,8'
2024-03-04 12:56:12 +01:00
$label . Text = 'Check apps that you wish to remove, uncheck apps that you wish to keep'
2024-03-04 00:10:24 +01:00
$form . Controls . Add ( $label )
2024-04-05 23:35:10 +02:00
$loadingLabel . Location = New-Object System . Drawing . Point ( 16 , 46 )
2024-03-29 16:56:29 +01:00
$loadingLabel . Size = New-Object System . Drawing . Size ( 300 , 418 )
$loadingLabel . Text = 'Loading apps...'
2024-03-04 12:56:12 +01:00
$loadingLabel . BackColor = " White "
$loadingLabel . Visible = $false
$form . Controls . Add ( $loadingLabel )
$onlyInstalledCheckBox . TabIndex = 6
2024-04-05 23:35:10 +02:00
$onlyInstalledCheckBox . Location = New-Object System . Drawing . Point ( 230 , 474 )
2024-03-04 12:56:12 +01:00
$onlyInstalledCheckBox . Size = New-Object System . Drawing . Size ( 150 , 20 )
$onlyInstalledCheckBox . Text = 'Only show installed apps'
$onlyInstalledCheckBox . add_CheckedChanged ( $load_Apps )
$form . Controls . Add ( $onlyInstalledCheckBox )
2024-04-05 23:35:10 +02:00
$checkUncheckCheckBox . TabIndex = 7
$checkUncheckCheckBox . Location = New-Object System . Drawing . Point ( 16 , 22 )
$checkUncheckCheckBox . Size = New-Object System . Drawing . Size ( 150 , 20 )
$checkUncheckCheckBox . Text = 'Check/Uncheck all'
$checkUncheckCheckBox . add_CheckedChanged ( $check_All )
$form . Controls . Add ( $checkUncheckCheckBox )
2024-03-04 00:10:24 +01:00
$selectionBox . FormattingEnabled = $True
$selectionBox . DataBindings . DefaultDataSourceUpdateMode = 0
$selectionBox . Name = " selectionBox "
2024-04-05 23:35:10 +02:00
$selectionBox . Location = New-Object System . Drawing . Point ( 13 , 43 )
2024-03-04 00:10:24 +01:00
$selectionBox . Size = New-Object System . Drawing . Size ( 374 , 424 )
$selectionBox . TabIndex = 3
2024-04-05 23:35:10 +02:00
$selectionBox . add_SelectedIndexChanged ( $selectionBox_SelectedIndexChanged )
$selectionBox . add_Click ( $selectionBox_MouseDown )
2024-03-04 00:10:24 +01:00
$form . Controls . Add ( $selectionBox )
# Save the initial state of the form
2024-03-04 12:56:12 +01:00
$initialFormWindowState = $form . WindowState
2024-03-04 00:10:24 +01:00
2024-03-04 12:56:12 +01:00
# Load apps into selectionBox
$form . add_Load ( $load_Apps )
2024-03-04 00:10:24 +01:00
# Focus selectionBox when form opens
$form . Add_Shown ( { $form . Activate ( ) ; $selectionBox . Focus ( ) } )
# Show the Form
return $form . ShowDialog ( )
}
2024-08-02 13:31:20 +02:00
# Returns list of apps from the specified file, it trims the app names and removes any comments
function ReadAppslistFromFile {
2024-01-31 22:19:50 +01:00
param (
2024-03-29 16:56:29 +01:00
$appsFilePath
2023-08-03 01:18:02 +02:00
)
2024-03-29 16:56:29 +01:00
$appsList = @ ( )
2023-08-03 22:24:27 +02:00
# Get list of apps from file at the path provided, and remove them one by one
2024-03-29 16:56:29 +01:00
Foreach ( $app in ( Get-Content -Path $appsFilePath | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } ) ) {
2023-08-03 22:24:27 +02:00
# Remove any comments from the Appname
2023-09-29 02:39:56 +02:00
if ( -not ( $app . IndexOf ( '#' ) -eq -1 ) ) {
2023-08-02 21:58:09 +02:00
$app = $app . Substring ( 0 , $app . IndexOf ( '#' ) )
}
2024-08-02 13:31:20 +02:00
# Remove any spaces before and after the Appname
$app = $app . Trim ( )
2020-11-02 20:01:00 +01:00
2023-08-03 22:40:19 +02:00
$appString = $app . Trim ( '*' )
2024-03-29 16:56:29 +01:00
$appsList + = $appString
2020-10-27 23:26:39 +01:00
}
2023-10-15 19:48:27 +02:00
2024-08-02 13:31:20 +02:00
return $appsList
2020-10-27 23:26:39 +01:00
}
2023-08-03 22:24:27 +02:00
2023-11-19 23:40:35 +01:00
# Removes apps specified during function call from all user accounts and from the OS image.
2024-03-29 16:56:29 +01:00
function RemoveApps {
2024-01-31 22:19:50 +01:00
param (
2023-11-19 23:40:35 +01:00
$appslist
)
2024-01-31 22:19:50 +01:00
Foreach ( $app in $appsList ) {
2024-03-04 12:56:12 +01:00
Write-Output " Attempting to remove $app ... "
2024-03-29 16:56:29 +01:00
if ( ( $app -eq " Microsoft.OneDrive " ) -or ( $app -eq " Microsoft.Edge " ) ) {
# Use winget to remove OneDrive and Edge
2025-05-10 13:02:48 +02:00
if ( $script:wingetInstalled -eq $false ) {
2024-08-02 13:31:20 +02:00
Write-Host " Error: WinGet is either not installed or is outdated, $app could not be removed " -ForegroundColor Red
2024-03-29 16:56:29 +01:00
}
else {
# Uninstall app via winget
2024-07-02 18:51:00 +02:00
Strip-Progress -ScriptBlock { winget uninstall - -accept -source -agreements - -disable -interactivity - -id $app } | Tee-Object -Variable wingetOutput
2024-11-26 22:52:45 +01:00
If ( ( $app -eq " Microsoft.Edge " ) -and ( Select-String -InputObject $wingetOutput -Pattern " Uninstall failed with exit code " ) ) {
2024-08-02 13:31:20 +02:00
Write-Host " Unable to uninstall Microsoft Edge via Winget " -ForegroundColor Red
2024-07-02 18:51:00 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Would you like to forcefully uninstall Edge? NOT RECOMMENDED! (y/n) " ) -eq 'y' ) {
2024-07-02 19:12:34 +02:00
Write-Output " "
2024-07-02 18:51:00 +02:00
ForceRemoveEdge
}
}
2024-03-29 16:56:29 +01:00
}
}
else {
# Use Remove-AppxPackage to remove all other apps
$app = '*' + $app + '*'
2023-11-19 23:40:35 +01:00
2024-03-29 16:56:29 +01:00
# Remove installed app for all existing users
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22000 ) {
2024-06-27 12:51:30 +02:00
# Windows 11 build 22000 or later
2024-10-02 00:42:22 +02:00
try {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction Continue
2024-11-01 18:01:40 +01:00
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Removed $app for all users " -ForegroundColor DarkGray
}
2024-10-02 00:42:22 +02:00
}
catch {
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Unable to remove $app for all users " -ForegroundColor Yellow
Write-Host $psitem . Exception . StackTrace -ForegroundColor Gray
}
2024-10-02 00:42:22 +02:00
}
2024-06-27 12:51:30 +02:00
}
else {
# Windows 10
2024-10-02 00:42:22 +02:00
try {
Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue
2024-11-01 18:01:40 +01:00
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Removed $app for current user " -ForegroundColor DarkGray
}
2024-10-02 00:42:22 +02:00
}
catch {
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Unable to remove $app for current user " -ForegroundColor Yellow
Write-Host $psitem . Exception . StackTrace -ForegroundColor Gray
}
2024-10-02 00:42:22 +02:00
}
try {
Get-AppxPackage -Name $app -PackageTypeFilter Main , Bundle , Resource -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue
2024-11-01 18:01:40 +01:00
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Removed $app for all users " -ForegroundColor DarkGray
}
2024-10-02 00:42:22 +02:00
}
catch {
2025-05-07 15:51:01 +02:00
if ( $DebugPreference -ne " SilentlyContinue " ) {
2024-11-01 18:01:40 +01:00
Write-Host " Unable to remove $app for all users " -ForegroundColor Yellow
Write-Host $psitem . Exception . StackTrace -ForegroundColor Gray
}
2024-10-02 00:42:22 +02:00
}
2024-06-27 12:51:30 +02:00
}
2023-11-19 23:40:35 +01:00
2024-03-29 16:56:29 +01:00
# Remove provisioned app from OS image, so the app won't be installed for any new users
2024-10-02 00:42:22 +02:00
try {
Get-AppxProvisionedPackage -Online | Where-Object { $_ . PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_ . PackageName }
}
catch {
Write-Host " Unable to remove $app from windows image " -ForegroundColor Yellow
Write-Host $psitem . Exception . StackTrace -ForegroundColor Gray
}
2024-03-29 16:56:29 +01:00
}
2023-11-19 23:40:35 +01:00
}
2024-08-02 13:31:20 +02:00
Write-Output " "
2023-11-19 23:40:35 +01:00
}
2024-08-02 13:31:20 +02:00
# Forcefully removes Microsoft Edge using it's uninstaller
2024-07-02 18:51:00 +02:00
function ForceRemoveEdge {
# Based on work from loadstring1 & ave9858
Write-Output " > Forcefully uninstalling Microsoft Edge... "
$regView = [ Microsoft.Win32.RegistryView ] :: Registry32
$hklm = [ Microsoft.Win32.RegistryKey ] :: OpenBaseKey ( [ Microsoft.Win32.RegistryHive ] :: LocalMachine , $regView )
$hklm . CreateSubKey ( 'SOFTWARE\Microsoft\EdgeUpdateDev' ) . SetValue ( 'AllowUninstall' , '' )
# Create stub (Creating this somehow allows uninstalling edge)
$edgeStub = " $env:SystemRoot \SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe "
New-Item $edgeStub -ItemType Directory | Out-Null
New-Item " $edgeStub \MicrosoftEdge.exe " | Out-Null
# Remove edge
$uninstallRegKey = $hklm . OpenSubKey ( 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge' )
2024-08-17 00:08:09 +02:00
if ( $null -ne $uninstallRegKey ) {
2024-07-02 18:51:00 +02:00
Write-Output " Running uninstaller... "
$uninstallString = $uninstallRegKey . GetValue ( 'UninstallString' ) + ' --force-uninstall'
Start-Process cmd . exe " /c $uninstallString " -WindowStyle Hidden -Wait
Write-Output " Removing leftover files... "
$edgePaths = @ (
" $env:ProgramData \Microsoft\Windows\Start Menu\Programs\Microsoft Edge.lnk " ,
" $env:APPDATA \Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk " ,
" $env:APPDATA \Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk " ,
2024-08-31 22:13:59 +02:00
" $env:APPDATA \Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk " ,
2024-07-02 18:51:00 +02:00
" $env:PUBLIC \Desktop\Microsoft Edge.lnk " ,
" $env:USERPROFILE \Desktop\Microsoft Edge.lnk " ,
" $edgeStub "
)
2025-05-16 18:26:06 +02:00
foreach ( $path in $edgePaths ) {
2024-07-02 18:51:00 +02:00
if ( Test-Path -Path $path ) {
Remove-Item -Path $path -Force -Recurse -ErrorAction SilentlyContinue
Write-Host " Removed $path " -ForegroundColor DarkGray
}
}
Write-Output " Cleaning up registry... "
# Remove ms edge from autostart
reg delete " HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run " / v " MicrosoftEdgeAutoLaunch_A9F6DCE4ABADF4F51CF45CD7129E3C6C " / f * > $null
reg delete " HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run " / v " Microsoft Edge Update " / f * > $null
reg delete " HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run " / v " MicrosoftEdgeAutoLaunch_A9F6DCE4ABADF4F51CF45CD7129E3C6C " / f * > $null
reg delete " HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run " / v " Microsoft Edge Update " / f * > $null
Write-Output " Microsoft Edge was uninstalled "
}
else {
Write-Output " "
Write-Host " Error: Unable to forcefully uninstall Microsoft Edge, uninstaller could not be found " -ForegroundColor Red
}
Write-Output " "
}
# Execute provided command and strips progress spinners/bars from console output
function Strip-Progress {
param (
[ ScriptBlock ] $ScriptBlock
)
# Regex pattern to match spinner characters and progress bar patterns
$progressPattern = 'Γû[Æê]|^\s+[-\\|/]\s+$'
# Corrected regex pattern for size formatting, ensuring proper capture groups are utilized
$sizePattern = '(\d+(\.\d{1,2})?)\s+(B|KB|MB|GB|TB|PB) /\s+(\d+(\.\d{1,2})?)\s+(B|KB|MB|GB|TB|PB)'
& $ScriptBlock 2 > & 1 | ForEach-Object {
if ( $_ -is [ System.Management.Automation.ErrorRecord ] ) {
" ERROR: $( $_ . Exception . Message ) "
} else {
$line = $_ -replace $progressPattern , '' -replace $sizePattern , ''
if ( -not ( [ string ] :: IsNullOrWhiteSpace ( $line ) ) -and -not ( $line . StartsWith ( ' ' ) ) ) {
$line
}
}
}
}
2022-04-09 18:52:16 +02:00
# Import & execute regfile
2023-05-15 16:38:11 -06:00
function RegImport {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$message ,
$path
2020-11-07 02:57:38 +01:00
)
2020-11-04 01:48:42 +01:00
2023-12-15 13:22:35 +01:00
Write-Output $message
2024-06-27 23:08:43 +02:00
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " Sysprep " ) ) {
2025-01-09 23:08:50 +01:00
$defaultUserPath = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , '\Default\NTUSER.DAT'
2024-08-31 22:13:59 +02:00
reg load " HKU\Default " $defaultUserPath | Out-Null
2025-03-05 23:39:29 +01:00
reg import " $PSScriptRoot \Regfiles\Sysprep\ $path "
reg unload " HKU\Default " | Out-Null
}
2025-05-10 13:02:48 +02:00
elseif ( $script:Params . ContainsKey ( " User " ) ) {
$userPath = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , " \ $( $script:Params . Item ( " User " ) ) \NTUSER.DAT "
2025-03-05 23:39:29 +01:00
reg load " HKU\Default " $userPath | Out-Null
reg import " $PSScriptRoot \Regfiles\Sysprep\ $path "
2024-06-27 23:08:43 +02:00
reg unload " HKU\Default " | Out-Null
2025-03-05 23:39:29 +01:00
}
else {
reg import " $PSScriptRoot \Regfiles\ $path "
2024-06-27 23:08:43 +02:00
}
2023-10-15 19:48:27 +02:00
Write-Output " "
2020-11-04 01:48:42 +01:00
}
2023-08-03 22:24:27 +02:00
2024-06-29 16:18:23 +02:00
# Restart the Windows Explorer process
2023-09-08 00:47:59 +02:00
function RestartExplorer {
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " Sysprep " ) -or $script:Params . ContainsKey ( " User " ) ) {
2025-02-12 13:07:44 +01:00
return
}
2024-06-29 16:18:23 +02:00
Write-Output " > Restarting Windows Explorer process to apply all changes... (This may cause some flickering) "
2023-09-08 00:47:59 +02:00
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " DisableMouseAcceleration " ) ) {
2025-04-16 12:56:37 +02:00
Write-Host " Warning: The Enhance Pointer Precision setting changes will only take effect after a reboot " -ForegroundColor Yellow
}
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " DisableStickyKeys " ) ) {
2025-04-16 12:56:37 +02:00
Write-Host " Warning: The Sticky Keys setting changes will only take effect after a reboot " -ForegroundColor Yellow
2025-02-13 21:08:47 +01:00
}
2025-02-12 13:07:44 +01:00
# Only restart if the powershell process matches the OS architecture.
2024-06-05 19:18:01 +02:00
# Restarting explorer from a 32bit Powershell window will fail on a 64bit OS
2025-02-12 13:07:44 +01:00
if ( [ Environment ] :: Is64BitProcess -eq [ Environment ] :: Is64BitOperatingSystem ) {
2024-06-05 19:53:59 +02:00
Stop-Process -processName: Explorer -Force
2024-06-05 19:18:01 +02:00
}
else {
2025-02-13 21:08:47 +01:00
Write-Warning " Unable to restart Windows Explorer process, please manually reboot your PC to apply all changes. "
2024-06-05 19:18:01 +02:00
}
2023-09-08 00:47:59 +02:00
}
2024-08-15 22:03:48 +02:00
# Replace the startmenu for all users, when using the default startmenuTemplate this clears all pinned apps
2023-09-08 00:47:59 +02:00
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
2024-08-15 22:03:48 +02:00
function ReplaceStartMenuForAllUsers {
2024-01-31 22:19:50 +01:00
param (
2024-08-15 22:03:48 +02:00
$startMenuTemplate = " $PSScriptRoot /Start/start2.bin "
2023-09-08 00:47:59 +02:00
)
2024-08-15 22:03:48 +02:00
Write-Output " > Removing all pinned apps from the start menu for all users... "
2023-09-08 00:47:59 +02:00
2024-05-14 23:56:58 +02:00
# Check if template bin file exists, return early if it doesn't
2024-08-15 22:03:48 +02:00
if ( -not ( Test-Path $startMenuTemplate ) ) {
2024-05-14 23:56:58 +02:00
Write-Host " Error: Unable to clear start menu, start2.bin file missing from script folder " -ForegroundColor Red
2024-08-17 00:08:09 +02:00
Write-Output " "
2024-05-14 23:56:58 +02:00
return
}
2024-08-15 22:03:48 +02:00
# Get path to start menu file for all users
2025-01-09 23:08:50 +01:00
$userPathString = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , " \*\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState "
2024-08-31 22:13:59 +02:00
$usersStartMenuPaths = get-childitem -path $userPathString
2023-09-08 00:47:59 +02:00
2024-08-15 22:03:48 +02:00
# Go through all users and replace the start menu file
ForEach ( $startMenuPath in $usersStartMenuPaths ) {
ReplaceStartMenu " $( $startMenuPath . Fullname ) \start2.bin " $startMenuTemplate
}
2024-06-27 23:08:43 +02:00
2024-08-15 22:03:48 +02:00
# Also replace the start menu file for the default user profile
2025-01-09 23:08:50 +01:00
$defaultStartMenuPath = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , '\Default\AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState'
2024-06-27 23:08:43 +02:00
2024-08-15 22:03:48 +02:00
# Create folder if it doesn't exist
2025-05-07 15:51:01 +02:00
if ( -not ( Test-Path $defaultStartMenuPath ) ) {
2024-08-31 22:13:59 +02:00
new-item $defaultStartMenuPath -ItemType Directory -Force | Out-Null
Write-Output " Created LocalState folder for default user profile "
2024-08-15 22:03:48 +02:00
}
2024-06-27 23:08:43 +02:00
2024-08-15 22:03:48 +02:00
# Copy template to default profile
2024-08-31 22:13:59 +02:00
Copy-Item -Path $startMenuTemplate -Destination $defaultStartMenuPath -Force
2024-08-15 22:03:48 +02:00
Write-Output " Replaced start menu for the default user profile "
Write-Output " "
}
2024-06-27 23:08:43 +02:00
2024-08-15 22:03:48 +02:00
# Replace the startmenu for all users, when using the default startmenuTemplate this clears all pinned apps
# Credit: https://lazyadmin.nl/win-11/customize-windows-11-start-menu-layout/
function ReplaceStartMenu {
param (
2025-05-19 00:01:49 +02:00
$startMenuTemplate = " $PSScriptRoot /Start/start2.bin " ,
$startMenuBinFile = " $env:LOCALAPPDATA \Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin "
2024-08-15 22:03:48 +02:00
)
2024-06-27 23:08:43 +02:00
2025-03-05 23:39:29 +01:00
# Change path to correct user if a user was specified
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " User " ) ) {
2025-03-05 23:39:29 +01:00
$startMenuBinFile = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , " \ $( GetUserName ) \AppData\Local\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start2.bin "
}
2024-06-27 23:08:43 +02:00
2024-08-15 22:03:48 +02:00
# Check if template bin file exists, return early if it doesn't
if ( -not ( Test-Path $startMenuTemplate ) ) {
2025-05-19 20:30:11 +02:00
Write-Host " Error: Unable to replace start menu, template file not found " -ForegroundColor Red
return
}
if ( [ IO.Path ] :: GetExtension ( $startMenuTemplate ) -ne " .bin " ) {
Write-Host " Error: Unable to replace start menu, template file is not a valid .bin file " -ForegroundColor Red
2024-08-15 22:03:48 +02:00
return
2024-06-27 23:08:43 +02:00
}
2023-09-08 00:47:59 +02:00
2024-08-15 22:03:48 +02:00
# Check if bin file exists, return early if it doesn't
if ( -not ( Test-Path $startMenuBinFile ) ) {
2025-05-19 20:30:11 +02:00
Write-Host " Error: Unable to replace start menu for user $( GetUserName ) , original start2.bin file not found " -ForegroundColor Red
2024-08-15 22:03:48 +02:00
return
}
2024-05-24 14:13:15 +02:00
2024-08-15 22:03:48 +02:00
$backupBinFile = $startMenuBinFile + " .bak "
2023-09-12 02:59:25 +02:00
2024-08-15 22:03:48 +02:00
# Backup current start menu file
Move-Item -Path $startMenuBinFile -Destination $backupBinFile -Force
# Copy template file
Copy-Item -Path $startMenuTemplate -Destination $startMenuBinFile -Force
2025-03-05 23:39:29 +01:00
Write-Output " Replaced start menu for user $( GetUserName ) "
2023-12-15 13:22:35 +01:00
}
# Add parameter to script and write to file
function AddParameter {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$parameterName ,
$message
)
# Add key if it doesn't already exist
2025-05-10 13:02:48 +02:00
if ( -not $script:Params . ContainsKey ( $parameterName ) ) {
$script:Params . Add ( $parameterName , $true )
2023-12-15 13:22:35 +01:00
}
# Create or clear file that stores last used settings
2025-05-07 15:51:01 +02:00
if ( -not ( Test-Path " $PSScriptRoot /SavedSettings " ) ) {
2024-03-29 16:56:29 +01:00
$null = New-Item " $PSScriptRoot /SavedSettings "
2023-12-15 13:22:35 +01:00
}
2025-05-10 13:02:48 +02:00
elseif ( $script:FirstSelection ) {
2024-03-29 16:56:29 +01:00
$null = Clear-Content " $PSScriptRoot /SavedSettings "
2023-12-15 13:22:35 +01:00
}
2024-02-23 12:25:11 +01:00
2025-05-10 13:02:48 +02:00
$script:FirstSelection = $false
2023-12-15 13:22:35 +01:00
# Create entry and add it to the file
2024-06-27 23:08:43 +02:00
$entry = " $parameterName #- $message "
2024-03-29 16:56:29 +01:00
Add-Content -Path " $PSScriptRoot /SavedSettings " -Value $entry
2023-12-15 13:22:35 +01:00
}
function PrintHeader {
2024-01-31 22:19:50 +01:00
param (
2023-12-15 13:22:35 +01:00
$title
)
2024-06-27 23:08:43 +02:00
$fullTitle = " Win11Debloat Script - $title "
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " Sysprep " ) ) {
2024-06-27 23:08:43 +02:00
$fullTitle = " $fullTitle (Sysprep mode) "
}
2024-07-17 19:45:00 +02:00
else {
2025-03-06 19:50:34 +01:00
$fullTitle = " $fullTitle (User: $( GetUserName ) ) "
2024-07-17 19:45:00 +02:00
}
2023-12-15 13:22:35 +01:00
Clear-Host
Write-Output " ------------------------------------------------------------------------------------------- "
Write-Output $fullTitle
Write-Output " ------------------------------------------------------------------------------------------- "
}
function PrintFromFile {
2024-01-31 22:19:50 +01:00
param (
2025-05-07 15:51:42 +02:00
$path ,
$title
2023-12-15 13:22:35 +01:00
)
Clear-Host
2025-05-07 15:51:42 +02:00
PrintHeader $title
2023-12-15 13:22:35 +01:00
# Get & print script menu from file
Foreach ( $line in ( Get-Content -Path $path ) ) {
Write-Output $line
}
2023-09-08 00:47:59 +02:00
}
2024-04-05 18:26:58 +02:00
function AwaitKeyToExit {
# Suppress prompt if Silent parameter was passed
if ( -not $Silent ) {
Write-Output " "
Write-Output " Press any key to exit... "
$null = [ System.Console ] :: ReadKey ( )
}
2025-05-10 16:42:03 +02:00
Stop-Transcript
Exit
2024-04-05 18:26:58 +02:00
}
2025-03-05 23:39:29 +01:00
function GetUserName {
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " User " ) ) {
return $script:Params . Item ( " User " )
2025-03-05 23:39:29 +01:00
}
2025-05-04 23:33:20 +02:00
return $env:USERNAME
2025-03-05 23:39:29 +01:00
}
2025-05-03 17:55:31 +02:00
function CreateSystemRestorePoint {
2025-05-05 22:47:31 +02:00
Write-Output " > Attempting to create a system restore point... "
$SysRestore = Get-ItemProperty -Path " HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore " -Name " RPSessionInterval "
if ( $SysRestore . RPSessionInterval -eq 0 ) {
2025-05-05 23:46:45 +02:00
if ( $Silent -or $ ( Read-Host -Prompt " System restore is disabled, would you like to enable it and create a restore point? (y/n) " ) -eq 'y' ) {
try {
Enable-ComputerRestore -Drive " $env:SystemDrive "
} catch {
Write-Host " Error: Failed to enable System Restore: $_ " -ForegroundColor Red
2025-05-05 22:47:31 +02:00
Write-Output " "
return
}
2025-05-05 23:46:45 +02:00
} else {
Write-Output " "
return
2025-05-05 22:47:31 +02:00
}
}
2025-05-03 17:55:31 +02:00
# Find existing restore points that are less than 24 hours old
try {
$recentRestorePoints = Get-ComputerRestorePoint | Where-Object { ( Get-Date ) - [ System.Management.ManagementDateTimeConverter ] :: ToDateTime ( $_ . CreationTime ) -le ( New-TimeSpan -Hours 24 ) }
} catch {
Write-Host " Error: Unable to retrieve existing restore points: $_ " -ForegroundColor Red
Write-Output " "
return
}
if ( $recentRestorePoints . Count -eq 0 ) {
2025-05-04 22:35:58 +02:00
try {
Checkpoint-Computer -Description " Restore point created by Win11Debloat " -RestorePointType " MODIFY_SETTINGS "
2025-05-05 22:47:31 +02:00
Write-Output " System restore point created successfully "
2025-05-04 22:35:58 +02:00
} catch {
Write-Host " Error: Unable to create restore point: $_ " -ForegroundColor Red
}
2025-05-05 22:47:31 +02:00
} else {
2025-05-03 17:55:31 +02:00
Write-Host " A recent restore point already exists, no new restore point was created. " -ForegroundColor Yellow
}
Write-Output " "
}
2025-02-13 21:08:47 +01:00
function DisplayCustomModeOptions {
# Get current Windows build version to compare against features
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
PrintHeader 'Custom Mode'
2025-05-05 22:47:31 +02:00
AddParameter 'CreateRestorePoint' 'Create a system restore point'
2025-05-03 17:55:31 +02:00
2025-02-13 21:08:47 +01:00
# Show options for removing apps, only continue on valid input
Do {
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) Don't remove any apps " -ForegroundColor Yellow
Write-Host " (1) Only remove the default selection of bloatware apps from 'Appslist.txt' " -ForegroundColor Yellow
Write-Host " (2) Remove default selection of bloatware apps, aswell as mail & calendar apps, developer apps and gaming apps " -ForegroundColor Yellow
Write-Host " (3) Select which apps to remove and which to keep " -ForegroundColor Yellow
$RemoveAppsInput = Read-Host " Remove any pre-installed apps? (n/1/2/3) "
# Show app selection form if user entered option 3
if ( $RemoveAppsInput -eq '3' ) {
$result = ShowAppSelectionForm
if ( $result -ne [ System.Windows.Forms.DialogResult ] :: OK ) {
# User cancelled or closed app selection, show error and change RemoveAppsInput so the menu will be shown again
Write-Output " "
Write-Host " Cancelled application selection, please try again " -ForegroundColor Red
$RemoveAppsInput = 'c'
}
Write-Output " "
}
}
while ( $RemoveAppsInput -ne 'n' -and $RemoveAppsInput -ne '0' -and $RemoveAppsInput -ne '1' -and $RemoveAppsInput -ne '2' -and $RemoveAppsInput -ne '3' )
# Select correct option based on user input
switch ( $RemoveAppsInput ) {
'1' {
AddParameter 'RemoveApps' 'Remove default selection of bloatware apps'
}
'2' {
AddParameter 'RemoveApps' 'Remove default selection of bloatware apps'
AddParameter 'RemoveCommApps' 'Remove the Mail, Calendar, and People apps'
AddParameter 'RemoveW11Outlook' 'Remove the new Outlook for Windows app'
AddParameter 'RemoveDevApps' 'Remove developer-related apps'
AddParameter 'RemoveGamingApps' 'Remove the Xbox App and Xbox Gamebar'
AddParameter 'DisableDVR' 'Disable Xbox game/screen recording'
}
'3' {
2025-05-10 13:02:48 +02:00
Write-Output " You have selected $( $script:SelectedApps . Count ) apps for removal "
2025-02-13 21:08:47 +01:00
2025-05-10 13:02:48 +02:00
AddParameter 'RemoveAppsCustom' " Remove $( $script:SelectedApps . Count ) apps: "
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable Xbox game/screen recording? Also stops gaming overlay popups (y/n) " ) -eq 'y' ) {
AddParameter 'DisableDVR' 'Disable Xbox game/screen recording'
}
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable telemetry, diagnostic data, activity history, app-launch tracking and targeted ads? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableTelemetry' 'Disable telemetry, diagnostic data, activity history, app-launch tracking & targeted ads'
}
Write-Output " "
2025-05-20 20:38:47 +02:00
if ( $ ( Read-Host -Prompt " Disable tips, tricks, suggestions and ads in start, settings, notifications, explorer and lockscreen? (y/n) " ) -eq 'y' ) {
2025-02-13 21:08:47 +01:00
AddParameter 'DisableSuggestions' 'Disable tips, tricks, suggestions and ads in start, settings, notifications and File Explorer'
2025-05-20 21:56:04 +02:00
AddParameter 'DisableSettings365Ads' 'Disable Microsoft 365 ads in Settings Home'
2025-02-13 21:08:47 +01:00
AddParameter 'DisableLockscreenTips' 'Disable tips & tricks on the lockscreen'
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable & remove bing web search, bing AI & cortana in Windows search? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableBing' 'Disable & remove bing web search, bing AI & cortana in Windows search'
}
# Only show this option for Windows 11 users running build 22621 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22621 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
2025-04-19 21:07:43 +02:00
if ( $ ( Read-Host -Prompt " Disable & remove Microsoft Copilot and Windows Recall snapshots? This applies to all users (y/n) " ) -eq 'y' ) {
AddParameter 'DisableCopilot' 'Disable and remove Microsoft Copilot'
2025-04-19 21:03:40 +02:00
AddParameter 'DisableRecall' 'Disable and remove Windows Recall snapshots'
2025-02-13 21:08:47 +01:00
}
}
2025-05-20 20:38:47 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable Windows Spotlight background on desktop? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableDesktopSpotlight' 'Disable the Windows Spotlight desktop background option.'
}
2025-02-13 21:08:47 +01:00
# Only show this option for Windows 11 users running build 22000 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22000 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Restore the old Windows 10 style context menu? (y/n) " ) -eq 'y' ) {
AddParameter 'RevertContextMenu' 'Restore the old Windows 10 style context menu'
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Turn off Enhance Pointer Precision, also known as mouse acceleration? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableMouseAcceleration' 'Turn off Enhance Pointer Precision (mouse acceleration)'
}
2025-04-16 12:56:37 +02:00
# Only show this option for Windows 11 users running build 26100 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 26100 ) {
2025-04-16 12:56:37 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable the Sticky Keys keyboard shortcut? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableStickyKeys' 'Disable the Sticky Keys keyboard shortcut'
}
}
2025-05-01 22:32:41 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable Fast Start-up? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableFastStartup' 'Disable Fast Start-up'
}
2025-02-13 21:08:47 +01:00
# Only show option for disabling context menu items for Windows 10 users or if the user opted to restore the Windows 10 context menu
2025-05-16 18:26:06 +02:00
if ( ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) -or $script:Params . ContainsKey ( 'RevertContextMenu' ) ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Do you want to disable any context menu options? (y/n) " ) -eq 'y' ) {
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the 'Include in library' option in the context menu? (y/n) " ) -eq 'y' ) {
AddParameter 'HideIncludeInLibrary' " Hide the 'Include in library' option in the context menu "
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the 'Give access to' option in the context menu? (y/n) " ) -eq 'y' ) {
AddParameter 'HideGiveAccessTo' " Hide the 'Give access to' option in the context menu "
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the 'Share' option in the context menu? (y/n) " ) -eq 'y' ) {
AddParameter 'HideShare' " Hide the 'Share' option in the context menu "
}
}
}
# Only show this option for Windows 11 users running build 22621 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22621 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Do you want to make any changes to the start menu? (y/n) " ) -eq 'y' ) {
Write-Output " "
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " Sysprep " ) ) {
2025-02-13 21:08:47 +01:00
if ( $ ( Read-Host -Prompt " Remove all pinned apps from the start menu for all existing and new users? (y/n) " ) -eq 'y' ) {
AddParameter 'ClearStartAllUsers' 'Remove all pinned apps from the start menu for existing and new users'
}
}
else {
Do {
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) Don't remove any pinned apps from the start menu " -ForegroundColor Yellow
2025-03-05 23:39:29 +01:00
Write-Host " (1) Remove all pinned apps from the start menu for this user only ( $( GetUserName ) ) " -ForegroundColor Yellow
2025-02-13 21:08:47 +01:00
Write-Host " (2) Remove all pinned apps from the start menu for all existing and new users " -ForegroundColor Yellow
$ClearStartInput = Read-Host " Remove all pinned apps from the start menu? (n/1/2) "
}
while ( $ClearStartInput -ne 'n' -and $ClearStartInput -ne '0' -and $ClearStartInput -ne '1' -and $ClearStartInput -ne '2' )
# Select correct option based on user input
switch ( $ClearStartInput ) {
'1' {
AddParameter 'ClearStart' " Remove all pinned apps from the start menu for this user only "
}
'2' {
AddParameter 'ClearStartAllUsers' " Remove all pinned apps from the start menu for all existing and new users "
}
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable & hide the recommended section in the start menu? This applies to all users (y/n) " ) -eq 'y' ) {
AddParameter 'DisableStartRecommended' 'Disable & hide the recommended section in the start menu.'
}
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Do you want to make any changes to the taskbar and related services? (y/n) " ) -eq 'y' ) {
# Only show these specific options for Windows 11 users running build 22000 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22000 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Align taskbar buttons to the left side? (y/n) " ) -eq 'y' ) {
AddParameter 'TaskbarAlignLeft' 'Align taskbar icons to the left'
}
# Show options for search icon on taskbar, only continue on valid input
Do {
Write-Output " "
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) No change " -ForegroundColor Yellow
Write-Host " (1) Hide search icon from the taskbar " -ForegroundColor Yellow
Write-Host " (2) Show search icon on the taskbar " -ForegroundColor Yellow
Write-Host " (3) Show search icon with label on the taskbar " -ForegroundColor Yellow
Write-Host " (4) Show search box on the taskbar " -ForegroundColor Yellow
$TbSearchInput = Read-Host " Hide or change the search icon on the taskbar? (n/1/2/3/4) "
}
while ( $TbSearchInput -ne 'n' -and $TbSearchInput -ne '0' -and $TbSearchInput -ne '1' -and $TbSearchInput -ne '2' -and $TbSearchInput -ne '3' -and $TbSearchInput -ne '4' )
# Select correct taskbar search option based on user input
switch ( $TbSearchInput ) {
'1' {
AddParameter 'HideSearchTb' 'Hide search icon from the taskbar'
}
'2' {
AddParameter 'ShowSearchIconTb' 'Show search icon on the taskbar'
}
'3' {
AddParameter 'ShowSearchLabelTb' 'Show search icon with label on the taskbar'
}
'4' {
AddParameter 'ShowSearchBoxTb' 'Show search box on the taskbar'
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the taskview button from the taskbar? (y/n) " ) -eq 'y' ) {
AddParameter 'HideTaskview' 'Hide the taskview button from the taskbar'
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Disable the widgets service and hide the icon from the taskbar? (y/n) " ) -eq 'y' ) {
AddParameter 'DisableWidgets' 'Disable the widget service & hide the widget (news and interests) icon from the taskbar'
}
# Only show this options for Windows users running build 22621 or earlier
2025-05-16 18:26:06 +02:00
if ( $WinVersion -le 22621 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the chat (meet now) icon from the taskbar? (y/n) " ) -eq 'y' ) {
AddParameter 'HideChat' 'Hide the chat (meet now) icon from the taskbar'
}
}
2025-04-16 12:31:18 +02:00
# Only show this options for Windows users running build 22631 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22631 ) {
2025-04-16 12:31:18 +02:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Enable the 'End Task' option in the taskbar right click menu? (y/n) " ) -eq 'y' ) {
AddParameter 'EnableEndTask' " Enable the 'End Task' option in the taskbar right click menu "
}
}
2025-02-13 21:08:47 +01:00
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Do you want to make any changes to File Explorer? (y/n) " ) -eq 'y' ) {
# Show options for changing the File Explorer default location
Do {
Write-Output " "
Write-Host " Options: " -ForegroundColor Yellow
Write-Host " (n) No change " -ForegroundColor Yellow
Write-Host " (1) Open File Explorer to 'Home' " -ForegroundColor Yellow
Write-Host " (2) Open File Explorer to 'This PC' " -ForegroundColor Yellow
Write-Host " (3) Open File Explorer to 'Downloads' " -ForegroundColor Yellow
Write-Host " (4) Open File Explorer to 'OneDrive' " -ForegroundColor Yellow
$ExplSearchInput = Read-Host " Change the default location that File Explorer opens to? (n/1/2/3/4) "
}
while ( $ExplSearchInput -ne 'n' -and $ExplSearchInput -ne '0' -and $ExplSearchInput -ne '1' -and $ExplSearchInput -ne '2' -and $ExplSearchInput -ne '3' -and $ExplSearchInput -ne '4' )
# Select correct taskbar search option based on user input
switch ( $ExplSearchInput ) {
'1' {
AddParameter 'ExplorerToHome' " Change the default location that File Explorer opens to 'Home' "
}
'2' {
AddParameter 'ExplorerToThisPC' " Change the default location that File Explorer opens to 'This PC' "
}
'3' {
AddParameter 'ExplorerToDownloads' " Change the default location that File Explorer opens to 'Downloads' "
}
'4' {
AddParameter 'ExplorerToOneDrive' " Change the default location that File Explorer opens to 'OneDrive' "
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Show hidden files, folders and drives? (y/n) " ) -eq 'y' ) {
AddParameter 'ShowHiddenFolders' 'Show hidden files, folders and drives'
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Show file extensions for known file types? (y/n) " ) -eq 'y' ) {
AddParameter 'ShowKnownFileExt' 'Show file extensions for known file types'
}
# Only show this option for Windows 11 users running build 22000 or later
2025-05-16 18:26:06 +02:00
if ( $WinVersion -ge 22000 ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the Home section from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
AddParameter 'HideHome' 'Hide the Home section from the File Explorer sidepanel'
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the Gallery section from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
AddParameter 'HideGallery' 'Hide the Gallery section from the File Explorer sidepanel'
}
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide duplicate removable drive entries from the File Explorer sidepanel so they only show under This PC? (y/n) " ) -eq 'y' ) {
AddParameter 'HideDupliDrive' 'Hide duplicate removable drive entries from the File Explorer sidepanel'
}
# Only show option for disabling these specific folders for Windows 10 users
2025-05-16 18:26:06 +02:00
if ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) {
2025-02-13 21:08:47 +01:00
Write-Output " "
if ( $ ( Read-Host -Prompt " Do you want to hide any folders from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the OneDrive folder from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
AddParameter 'HideOnedrive' 'Hide the OneDrive folder in the File Explorer sidepanel'
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the 3D objects folder from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
AddParameter 'Hide3dObjects' " Hide the 3D objects folder under 'This pc' in File Explorer "
}
Write-Output " "
if ( $ ( Read-Host -Prompt " Hide the music folder from the File Explorer sidepanel? (y/n) " ) -eq 'y' ) {
AddParameter 'HideMusic' " Hide the music folder under 'This pc' in File Explorer "
}
}
}
}
# Suppress prompt if Silent parameter was passed
if ( -not $Silent ) {
Write-Output " "
Write-Output " "
Write-Output " "
Write-Output " Press enter to confirm your choices and execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
}
PrintHeader 'Custom Mode'
}
2024-06-27 23:08:43 +02:00
##################################################################################################################
# #
# SCRIPT START #
# #
##################################################################################################################
# Check if winget is installed & if it is, check if the version is at least v1.4
2025-02-25 22:49:25 +01:00
if ( ( Get-AppxPackage -Name " *Microsoft.DesktopAppInstaller* " ) -and ( [ int ] ( ( ( winget -v ) -replace 'v' , '' ) . split ( '.' ) [ 0 . .1 ] -join '' ) -gt 14 ) ) {
2025-05-10 13:02:48 +02:00
$script:wingetInstalled = $true
2024-03-29 16:56:29 +01:00
}
2024-04-01 14:07:59 +02:00
else {
2025-05-10 13:02:48 +02:00
$script:wingetInstalled = $false
2024-05-05 06:20:19 -04:00
# Show warning that requires user confirmation, Suppress confirmation if Silent parameter was passed
if ( -not $Silent ) {
Write-Warning " Winget is not installed or outdated. This may prevent Win11Debloat from removing certain apps. "
Write-Output " "
Write-Output " Press any key to continue anyway... "
2024-06-26 20:27:25 +02:00
$null = [ System.Console ] :: ReadKey ( )
2024-05-05 06:20:19 -04:00
}
2024-03-29 16:56:29 +01:00
}
2024-06-27 23:08:43 +02:00
# Get current Windows build version to compare against features
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
2025-05-10 13:02:48 +02:00
$script:Params = $PSBoundParameters
$script:FirstSelection = $true
$SPParams = 'WhatIf' , 'Confirm' , 'Verbose' , 'Silent' , 'Sysprep' , 'Debug' , 'User' , 'CreateRestorePoint' , 'LogPath'
2023-09-27 21:03:25 +02:00
$SPParamCount = 0
2024-03-01 13:54:02 +01:00
# Count how many SPParams exist within Params
2024-03-29 16:56:29 +01:00
# This is later used to check if any options were selected
2023-12-15 13:22:35 +01:00
foreach ( $Param in $SPParams ) {
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( $Param ) ) {
2023-09-27 21:03:25 +02:00
$SPParamCount + +
}
}
2024-08-17 00:08:09 +02:00
# Hide progress bars for app removal, as they block Win11Debloat's output
2025-05-10 13:02:48 +02:00
if ( -not ( $script:Params . ContainsKey ( " Verbose " ) ) ) {
2024-08-17 00:08:09 +02:00
$ProgressPreference = 'SilentlyContinue'
}
else {
2025-05-07 15:51:01 +02:00
Write-Host " Verbose mode is enabled "
Write-Output " "
Write-Output " Press any key to continue... "
$null = [ System.Console ] :: ReadKey ( )
2024-08-17 00:08:09 +02:00
$ProgressPreference = 'Continue'
}
2025-03-05 23:39:29 +01:00
# Make sure all requirements for Sysprep are met, if Sysprep is enabled
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " Sysprep " ) ) {
2025-01-09 23:08:50 +01:00
$defaultUserPath = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , '\Default\NTUSER.DAT'
2024-08-31 22:13:59 +02:00
2024-06-27 23:08:43 +02:00
# Exit script if default user directory or NTUSER.DAT file cannot be found
2024-08-31 22:13:59 +02:00
if ( -not ( Test-Path " $defaultUserPath " ) ) {
Write-Host " Error: Unable to start Win11Debloat in Sysprep mode, cannot find default user folder at ' $defaultUserPath ' " -ForegroundColor Red
2024-06-27 23:08:43 +02:00
AwaitKeyToExit
}
# Exit script if run in Sysprep mode on Windows 10
if ( $WinVersion -lt 22000 ) {
Write-Host " Error: Win11Debloat Sysprep mode is not supported on Windows 10 " -ForegroundColor Red
AwaitKeyToExit
}
}
2025-03-05 23:39:29 +01:00
# Make sure all requirements for User mode are met, if User is specified
2025-05-10 13:02:48 +02:00
if ( $script:Params . ContainsKey ( " User " ) ) {
$userPath = $env:USERPROFILE -Replace ( '\\' + $env:USERNAME + '$' ) , " \ $( $script:Params . Item ( " User " ) ) \NTUSER.DAT "
2025-03-05 23:39:29 +01:00
# Exit script if user directory or NTUSER.DAT file cannot be found
if ( -not ( Test-Path " $userPath " ) ) {
2025-05-10 13:02:48 +02:00
Write-Host " Error: Unable to run Win11Debloat for user $( $script:Params . Item ( " User " ) ) , cannot find user data at ' $userPath ' " -ForegroundColor Red
2025-03-05 23:39:29 +01:00
AwaitKeyToExit
}
}
2024-06-05 09:17:24 +02:00
# Remove SavedSettings file if it exists and is empty
2024-06-05 19:18:01 +02:00
if ( ( Test-Path " $PSScriptRoot /SavedSettings " ) -and ( [ String ] :: IsNullOrWhiteSpace ( ( Get-content " $PSScriptRoot /SavedSettings " ) ) ) ) {
2024-06-05 09:17:24 +02:00
Remove-Item -Path " $PSScriptRoot /SavedSettings " -recurse
2023-12-15 13:22:35 +01:00
}
2025-04-19 15:16:47 +02:00
# Only run the app selection form if the 'RunAppsListGenerator' parameter was passed to the script
if ( $RunAppConfigurator -or $RunAppsListGenerator ) {
PrintHeader " Custom Apps List Generator "
2024-03-11 23:38:19 +01:00
2024-03-29 16:56:29 +01:00
$result = ShowAppSelectionForm
2024-03-11 23:38:19 +01:00
# Show different message based on whether the app selection was saved or cancelled
2024-03-29 16:56:29 +01:00
if ( $result -ne [ System.Windows.Forms.DialogResult ] :: OK ) {
2025-04-19 15:16:47 +02:00
Write-Host " Application selection window was closed without saving. " -ForegroundColor Red
2024-03-11 23:38:19 +01:00
}
else {
2025-04-14 21:02:58 +02:00
Write-Output " Your app selection was saved to the 'CustomAppsList' file, found at: "
Write-Host " $PSScriptRoot " -ForegroundColor Yellow
2024-03-11 23:38:19 +01:00
}
2024-04-05 18:26:58 +02:00
AwaitKeyToExit
2024-03-11 23:38:19 +01:00
}
2023-08-07 00:49:41 +02:00
# Change script execution based on provided parameters or user input
2025-05-10 13:02:48 +02:00
if ( ( -not $script:Params . Count ) -or $RunDefaults -or $RunWin11Defaults -or $RunSavedSettings -or ( $SPParamCount -eq $script:Params . Count ) ) {
2023-08-03 01:18:02 +02:00
if ( $RunDefaults -or $RunWin11Defaults ) {
2024-04-05 23:35:10 +02:00
$Mode = '1'
2020-11-07 02:57:38 +01:00
}
2025-01-09 21:33:28 +01:00
elseif ( $RunSavedSettings ) {
2025-05-07 15:51:01 +02:00
if ( -not ( Test-Path " $PSScriptRoot /SavedSettings " ) ) {
2025-01-09 21:33:28 +01:00
PrintHeader 'Custom Mode'
Write-Host " Error: No saved settings found, no changes were made " -ForegroundColor Red
AwaitKeyToExit
}
$Mode = '4'
}
2023-05-15 16:38:11 -06:00
else {
2023-08-03 22:24:27 +02:00
# Show menu and wait for user input, loops until valid input is provided
2022-09-08 17:20:53 +02:00
Do {
2024-03-29 16:56:29 +01:00
$ModeSelectionMessage = " Please select an option (1/2/3/0) "
PrintHeader 'Menu'
2023-08-03 22:24:27 +02:00
2025-05-14 00:09:56 +02:00
Write-Output " (1) Default mode: Quickly apply the recommended changes "
Write-Output " (2) Custom mode: Manually select what changes to make "
2024-03-29 16:56:29 +01:00
Write-Output " (3) App removal mode: Select & remove apps, without making other changes "
2023-12-15 13:22:35 +01:00
2024-03-29 16:56:29 +01:00
# Only show this option if SavedSettings file exists
if ( Test-Path " $PSScriptRoot /SavedSettings " ) {
Write-Output " (4) Apply saved custom settings from last time "
$ModeSelectionMessage = " Please select an option (1/2/3/4/0) "
2023-08-03 22:24:27 +02:00
}
2023-12-15 13:22:35 +01:00
Write-Output " "
2024-07-09 22:02:32 +02:00
Write-Output " (0) Show more information "
2023-12-15 13:22:35 +01:00
Write-Output " "
Write-Output " "
$Mode = Read-Host $ModeSelectionMessage
2020-11-07 02:57:38 +01:00
2023-05-15 16:38:11 -06:00
if ( $Mode -eq '0' ) {
2025-05-16 18:26:06 +02:00
# Print information screen from file
2025-05-07 15:51:42 +02:00
PrintFromFile " $PSScriptRoot /Assets/Menus/Info " " Information "
2023-08-03 22:24:27 +02:00
2022-09-08 17:20:53 +02:00
Write-Output " Press any key to go back... "
2024-06-26 20:27:25 +02:00
$null = [ System.Console ] :: ReadKey ( )
2022-09-08 17:20:53 +02:00
}
2025-05-07 15:51:01 +02:00
elseif ( ( $Mode -eq '4' ) -and -not ( Test-Path " $PSScriptRoot /SavedSettings " ) ) {
2024-04-05 23:35:10 +02:00
$Mode = $null
2023-12-15 13:22:35 +01:00
}
2022-09-08 17:20:53 +02:00
}
2024-03-29 16:56:29 +01:00
while ( $Mode -ne '1' -and $Mode -ne '2' -and $Mode -ne '3' -and $Mode -ne '4' )
2020-11-07 02:57:38 +01:00
}
2020-11-06 12:48:13 +01:00
2022-04-09 18:52:16 +02:00
# Add execution parameters based on the mode
2023-05-15 16:38:11 -06:00
switch ( $Mode ) {
2024-03-29 16:56:29 +01:00
# Default mode, loads defaults after confirmation
2023-05-15 16:38:11 -06:00
'1' {
2025-05-16 18:26:06 +02:00
# Show the default settings with confirmation, unless Silent parameter was passed
2024-03-29 16:56:29 +01:00
if ( -not $Silent ) {
2025-05-07 15:51:42 +02:00
PrintFromFile " $PSScriptRoot /Assets/Menus/DefaultSettings " " Default Mode "
2024-03-29 16:56:29 +01:00
Write-Output " Press enter to execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
}
2025-05-03 17:55:31 +02:00
$DefaultParameterNames = 'CreateRestorePoint' , 'RemoveApps' , 'DisableTelemetry' , 'DisableBing' , 'DisableLockscreenTips' , 'DisableSuggestions' , 'ShowKnownFileExt' , 'DisableWidgets' , 'HideChat' , 'DisableCopilot' , 'DisableFastStartup'
2023-12-15 13:22:35 +01:00
2024-03-29 16:56:29 +01:00
PrintHeader 'Default Mode'
2023-09-29 02:39:56 +02:00
2025-05-16 18:26:06 +02:00
# Add default parameters, if they don't already exist
2023-09-29 02:39:56 +02:00
foreach ( $ParameterName in $DefaultParameterNames ) {
2025-05-16 18:26:06 +02:00
if ( -not $script:Params . ContainsKey ( $ParameterName ) ) {
2025-05-10 13:02:48 +02:00
$script:Params . Add ( $ParameterName , $true )
2023-09-29 02:39:56 +02:00
}
}
2024-01-31 22:19:50 +01:00
# Only add this option for Windows 10 users, if it doesn't already exist
2025-05-10 13:02:48 +02:00
if ( ( get-ciminstance -query " select caption from win32_operatingsystem where caption like '%Windows 10%' " ) -and ( -not $script:Params . ContainsKey ( 'Hide3dObjects' ) ) ) {
$script:Params . Add ( 'Hide3dObjects' , $Hide3dObjects )
2023-08-03 01:18:02 +02:00
}
2021-12-15 21:45:48 +01:00
}
2022-09-08 17:20:53 +02:00
2024-03-29 16:56:29 +01:00
# Custom mode, show & add options based on user input
2023-08-03 01:18:02 +02:00
'2' {
2025-02-13 21:08:47 +01:00
DisplayCustomModeOptions
2023-12-15 13:22:35 +01:00
}
2024-03-29 16:56:29 +01:00
# App removal, remove apps based on user selection
2023-12-15 13:22:35 +01:00
'3' {
2024-03-29 16:56:29 +01:00
PrintHeader " App Removal "
$result = ShowAppSelectionForm
if ( $result -eq [ System.Windows.Forms.DialogResult ] :: OK ) {
2025-05-10 13:02:48 +02:00
Write-Output " You have selected $( $script:SelectedApps . Count ) apps for removal "
AddParameter 'RemoveAppsCustom' " Remove $( $script:SelectedApps . Count ) apps: "
2024-03-29 16:56:29 +01:00
# Suppress prompt if Silent parameter was passed
if ( -not $Silent ) {
2025-05-07 15:51:01 +02:00
Write-Output " "
2024-03-29 16:56:29 +01:00
Write-Output " "
Write-Output " Press enter to remove the selected apps or press CTRL+C to quit... "
Read-Host | Out-Null
2024-07-02 18:51:00 +02:00
PrintHeader " App Removal "
2024-03-29 16:56:29 +01:00
}
}
else {
2024-08-02 13:31:20 +02:00
Write-Host " Selection was cancelled, no apps have been removed " -ForegroundColor Red
2024-07-02 18:51:00 +02:00
Write-Output " "
2024-03-29 16:56:29 +01:00
}
}
2025-05-16 18:26:06 +02:00
# Load custom options from the "SavedSettings" file
2024-03-29 16:56:29 +01:00
'4' {
2025-01-09 21:33:28 +01:00
PrintHeader 'Custom Mode'
Write-Output " Win11Debloat will make the following changes: "
2024-03-29 16:56:29 +01:00
2025-05-16 18:26:06 +02:00
# Print the saved settings info from file
2025-01-09 21:33:28 +01:00
Foreach ( $line in ( Get-Content -Path " $PSScriptRoot /SavedSettings " ) ) {
# Remove any spaces before and after the line
$line = $line . Trim ( )
# Check if the line contains a comment
if ( -not ( $line . IndexOf ( '#' ) -eq -1 ) ) {
$parameterName = $line . Substring ( 0 , $line . IndexOf ( '#' ) )
# Print parameter description and add parameter to Params list
if ( $parameterName -eq " RemoveAppsCustom " ) {
if ( -not ( Test-Path " $PSScriptRoot /CustomAppsList " ) ) {
# Apps file does not exist, skip
continue
2024-03-29 16:56:29 +01:00
}
2025-01-09 21:33:28 +01:00
$appsList = ReadAppslistFromFile " $PSScriptRoot /CustomAppsList "
Write-Output " - Remove $( $appsList . Count ) apps: "
Write-Host $appsList -ForegroundColor DarkGray
}
else {
Write-Output $line . Substring ( ( $line . IndexOf ( '#' ) + 1 ) , ( $line . Length - $line . IndexOf ( '#' ) - 1 ) )
}
2024-03-29 16:56:29 +01:00
2025-05-16 18:26:06 +02:00
if ( -not $script:Params . ContainsKey ( $parameterName ) ) {
2025-05-10 13:02:48 +02:00
$script:Params . Add ( $parameterName , $true )
2024-03-29 16:56:29 +01:00
}
}
2025-01-09 21:33:28 +01:00
}
2024-03-29 16:56:29 +01:00
2025-01-09 21:33:28 +01:00
if ( -not $Silent ) {
2024-03-29 16:56:29 +01:00
Write-Output " "
Write-Output " "
Write-Output " Press enter to execute the script or press CTRL+C to quit... "
Read-Host | Out-Null
}
PrintHeader 'Custom Mode'
2020-11-07 02:57:38 +01:00
}
}
2020-11-06 12:48:13 +01:00
}
2023-05-15 16:38:11 -06:00
else {
2024-03-29 16:56:29 +01:00
PrintHeader 'Custom Mode'
2020-11-06 12:48:13 +01:00
}
2024-03-01 13:54:02 +01:00
# If the number of keys in SPParams equals the number of keys in Params then no modifications/changes were selected
# or added by the user, and the script can exit without making any changes.
2025-05-10 13:02:48 +02:00
if ( $SPParamCount -eq $script:Params . Keys . Count ) {
2023-09-28 16:11:04 +02:00
Write-Output " The script completed without making any changes. "
2024-08-02 13:31:20 +02:00
2024-04-05 18:26:58 +02:00
AwaitKeyToExit
2020-10-27 23:26:39 +01:00
}
2025-02-13 21:08:47 +01:00
2025-05-04 23:33:20 +02:00
# Execute all selected/provided parameters
2025-05-10 13:02:48 +02:00
switch ( $script:Params . Keys ) {
2025-05-04 23:33:20 +02:00
'CreateRestorePoint' {
CreateSystemRestorePoint
continue
}
'RemoveApps' {
$appsList = ReadAppslistFromFile " $PSScriptRoot /Appslist.txt "
Write-Output " > Removing default selection of $( $appsList . Count ) apps... "
RemoveApps $appsList
continue
}
'RemoveAppsCustom' {
if ( -not ( Test-Path " $PSScriptRoot /CustomAppsList " ) ) {
Write-Host " > Error: Could not load custom apps list from file, no apps were removed " -ForegroundColor Red
2025-02-13 21:08:47 +01:00
Write-Output " "
continue
}
2025-05-04 23:33:20 +02:00
$appsList = ReadAppslistFromFile " $PSScriptRoot /CustomAppsList "
Write-Output " > Removing $( $appsList . Count ) apps... "
RemoveApps $appsList
continue
}
'RemoveCommApps' {
$appsList = 'Microsoft.windowscommunicationsapps' , 'Microsoft.People'
2025-05-10 16:42:03 +02:00
Write-Output " > Removing Mail, Calendar and People apps... "
2025-05-04 23:33:20 +02:00
RemoveApps $appsList
continue
}
'RemoveW11Outlook' {
$appsList = 'Microsoft.OutlookForWindows'
Write-Output " > Removing new Outlook for Windows app... "
RemoveApps $appsList
continue
}
'RemoveDevApps' {
$appsList = 'Microsoft.PowerAutomateDesktop' , 'Microsoft.RemoteDesktop' , 'Windows.DevHome'
Write-Output " > Removing developer-related related apps... "
RemoveApps $appsList
continue
}
'RemoveGamingApps' {
$appsList = 'Microsoft.GamingApp' , 'Microsoft.XboxGameOverlay' , 'Microsoft.XboxGamingOverlay'
Write-Output " > Removing gaming related apps... "
RemoveApps $appsList
continue
2023-09-28 16:11:04 +02:00
}
2025-05-04 23:33:20 +02:00
'RemoveHPApps' {
$appsList = 'AD2F1837.HPAIExperienceCenter' , 'AD2F1837.HPJumpStarts' , 'AD2F1837.HPPCHardwareDiagnosticsWindows' , 'AD2F1837.HPPowerManager' , 'AD2F1837.HPPrivacySettings' , 'AD2F1837.HPSupportAssistant' , 'AD2F1837.HPSureShieldAI' , 'AD2F1837.HPSystemInformation' , 'AD2F1837.HPQuickDrop' , 'AD2F1837.HPWorkWell' , 'AD2F1837.myHP' , 'AD2F1837.HPDesktopSupportUtilities' , 'AD2F1837.HPQuickTouch' , 'AD2F1837.HPEasyClean' , 'AD2F1837.HPConnectedMusic' , 'AD2F1837.HPFileViewer' , 'AD2F1837.HPRegistration' , 'AD2F1837.HPWelcome' , 'AD2F1837.HPConnectedPhotopoweredbySnapfish' , 'AD2F1837.HPPrinterControl'
Write-Output " > Removing HP apps... "
RemoveApps $appsList
continue
}
" ForceRemoveEdge " {
ForceRemoveEdge
continue
}
'DisableDVR' {
RegImport " > Disabling Xbox game/screen recording... " " Disable_DVR.reg "
continue
}
'DisableTelemetry' {
RegImport " > Disabling telemetry, diagnostic data, activity history, app-launch tracking and targeted ads... " " Disable_Telemetry.reg "
continue
}
{ $_ -in " DisableSuggestions " , " DisableWindowsSuggestions " } {
RegImport " > Disabling tips, tricks, suggestions and ads across Windows... " " Disable_Windows_Suggestions.reg "
continue
}
2025-05-20 21:56:04 +02:00
'DisableSettings365Ads' {
RegImport " > Disabling Microsoft 365 ads in Settings Home... " " Disable_Settings_365_Ads.reg "
2025-05-04 23:33:20 +02:00
continue
}
{ $_ -in " DisableLockscrTips " , " DisableLockscreenTips " } {
RegImport " > Disabling tips & tricks on the lockscreen... " " Disable_Lockscreen_Tips.reg "
continue
}
2025-05-20 21:56:04 +02:00
'DisableDesktopSpotlight' {
RegImport " > Disabling the 'Windows Spotlight' desktop background option... " " Disable_Desktop_Spotlight.reg "
continue
}
'DisableSettingsHome' {
RegImport " > Disabling the Settings Home page... " " Disable_Settings_Home.reg "
continue
}
2025-05-04 23:33:20 +02:00
{ $_ -in " DisableBingSearches " , " DisableBing " } {
RegImport " > Disabling bing web search, bing AI & cortana in Windows search... " " Disable_Bing_Cortana_In_Search.reg "
# Also remove the app package for bing search
$appsList = 'Microsoft.BingSearch'
RemoveApps $appsList
continue
}
'DisableCopilot' {
RegImport " > Disabling & removing Microsoft Copilot... " " Disable_Copilot.reg "
2020-10-27 23:26:39 +01:00
2025-05-04 23:33:20 +02:00
# Also remove the app package for copilot
$appsList = 'Microsoft.Copilot'
RemoveApps $appsList
continue
}
'DisableRecall' {
RegImport " > Disabling Windows Recall snapshots... " " Disable_AI_Recall.reg "
continue
}
'RevertContextMenu' {
RegImport " > Restoring the old Windows 10 style context menu... " " Disable_Show_More_Options_Context_Menu.reg "
continue
}
'DisableMouseAcceleration' {
RegImport " > Turning off Enhanced Pointer Precision... " " Disable_Enhance_Pointer_Precision.reg "
continue
}
'DisableStickyKeys' {
RegImport " > Disabling the Sticky Keys keyboard shortcut... " " Disable_Sticky_Keys_Shortcut.reg "
continue
}
'DisableFastStartup' {
RegImport " > Disabling Fast Start-up... " " Disable_Fast_Startup.reg "
continue
}
'ClearStart' {
Write-Output " > Removing all pinned apps from the start menu for user $( GetUserName ) ... "
ReplaceStartMenu
Write-Output " "
continue
}
2025-05-19 00:01:49 +02:00
'ReplaceStart' {
Write-Output " > Replacing the start menu for user $( GetUserName ) ... "
ReplaceStartMenu $script:Params . Item ( " ReplaceStart " )
Write-Output " "
continue
}
2025-05-04 23:33:20 +02:00
'ClearStartAllUsers' {
ReplaceStartMenuForAllUsers
continue
}
2025-05-19 00:01:49 +02:00
'ReplaceStartAllUsers' {
ReplaceStartMenuForAllUsers $script:Params . Item ( " ReplaceStartAllUsers " )
continue
}
2025-05-04 23:33:20 +02:00
'DisableStartRecommended' {
RegImport " > Disabling and hiding the start menu recommended section... " " Disable_Start_Recommended.reg "
continue
}
'TaskbarAlignLeft' {
RegImport " > Aligning taskbar buttons to the left... " " Align_Taskbar_Left.reg "
continue
}
'HideSearchTb' {
RegImport " > Hiding the search icon from the taskbar... " " Hide_Search_Taskbar.reg "
continue
}
'ShowSearchIconTb' {
RegImport " > Changing taskbar search to icon only... " " Show_Search_Icon.reg "
continue
}
'ShowSearchLabelTb' {
RegImport " > Changing taskbar search to icon with label... " " Show_Search_Icon_And_Label.reg "
continue
}
'ShowSearchBoxTb' {
RegImport " > Changing taskbar search to search box... " " Show_Search_Box.reg "
continue
}
'HideTaskview' {
RegImport " > Hiding the taskview button from the taskbar... " " Hide_Taskview_Taskbar.reg "
continue
}
{ $_ -in " HideWidgets " , " DisableWidgets " } {
RegImport " > Disabling the widget service and hiding the widget icon from the taskbar... " " Disable_Widgets_Taskbar.reg "
continue
}
{ $_ -in " HideChat " , " DisableChat " } {
RegImport " > Hiding the chat icon from the taskbar... " " Disable_Chat_Taskbar.reg "
continue
}
'EnableEndTask' {
RegImport " > Enabling the 'End Task' option in the taskbar right click menu... " " Enable_End_Task.reg "
continue
}
'ExplorerToHome' {
RegImport " > Changing the default location that File Explorer opens to ` Home ` ... " " Launch_File_Explorer_To_Home.reg "
continue
}
'ExplorerToThisPC' {
RegImport " > Changing the default location that File Explorer opens to `T his PC ` ... " " Launch_File_Explorer_To_This_PC.reg "
continue
}
'ExplorerToDownloads' {
RegImport " > Changing the default location that File Explorer opens to ` Downloads ` ... " " Launch_File_Explorer_To_Downloads.reg "
continue
}
'ExplorerToOneDrive' {
RegImport " > Changing the default location that File Explorer opens to ` OneDrive ` ... " " Launch_File_Explorer_To_OneDrive.reg "
continue
}
'ShowHiddenFolders' {
RegImport " > Unhiding hidden files, folders and drives... " " Show_Hidden_Folders.reg "
continue
}
'ShowKnownFileExt' {
RegImport " > Enabling file extensions for known file types... " " Show_Extensions_For_Known_File_Types.reg "
continue
}
'HideHome' {
RegImport " > Hiding the home section from the File Explorer navigation pane... " " Hide_Home_from_Explorer.reg "
continue
}
'HideGallery' {
RegImport " > Hiding the gallery section from the File Explorer navigation pane... " " Hide_Gallery_from_Explorer.reg "
continue
}
'HideDupliDrive' {
RegImport " > Hiding duplicate removable drive entries from the File Explorer navigation pane... " " Hide_duplicate_removable_drives_from_navigation_pane_of_File_Explorer.reg "
continue
}
{ $_ -in " HideOnedrive " , " DisableOnedrive " } {
RegImport " > Hiding the OneDrive folder from the File Explorer navigation pane... " " Hide_Onedrive_Folder.reg "
continue
}
{ $_ -in " Hide3dObjects " , " Disable3dObjects " } {
RegImport " > Hiding the 3D objects folder from the File Explorer navigation pane... " " Hide_3D_Objects_Folder.reg "
continue
}
{ $_ -in " HideMusic " , " DisableMusic " } {
RegImport " > Hiding the music folder from the File Explorer navigation pane... " " Hide_Music_folder.reg "
continue
}
{ $_ -in " HideIncludeInLibrary " , " DisableIncludeInLibrary " } {
RegImport " > Hiding 'Include in library' in the context menu... " " Disable_Include_in_library_from_context_menu.reg "
continue
}
{ $_ -in " HideGiveAccessTo " , " DisableGiveAccessTo " } {
RegImport " > Hiding 'Give access to' in the context menu... " " Disable_Give_access_to_context_menu.reg "
continue
}
{ $_ -in " HideShare " , " DisableShare " } {
RegImport " > Hiding 'Share' in the context menu... " " Disable_Share_from_context_menu.reg "
continue
}
}
2023-09-27 21:03:25 +02:00
2025-05-04 23:33:20 +02:00
RestartExplorer
2023-09-27 21:03:25 +02:00
2025-05-04 23:33:20 +02:00
Write-Output " "
Write-Output " "
Write-Output " "
Write-Output " Script completed! Please check above for any errors. "
AwaitKeyToExit