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 (
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$CLI,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$Silent,
|
2026-03-22 22:07:51 +01:00
|
|
|
[switch]$Undo,
|
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-12-29 01:03:14 +01:00
|
|
|
[switch]$NoRestartExplorer,
|
2025-05-03 17:55:31 +02:00
|
|
|
[switch]$CreateRestorePoint,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$RunAppsListGenerator,
|
2025-09-13 23:36:38 +02:00
|
|
|
[switch]$RunDefaults,
|
|
|
|
|
[switch]$RunDefaultsLite,
|
2025-01-09 21:33:28 +01:00
|
|
|
[switch]$RunSavedSettings,
|
2025-12-26 20:36:51 +01:00
|
|
|
[string]$Apps,
|
2026-02-12 22:50:22 +01:00
|
|
|
[string]$AppRemovalTarget,
|
2025-12-26 20:36:51 +01:00
|
|
|
[switch]$RemoveApps,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$RemoveAppsCustom,
|
|
|
|
|
[switch]$RemoveGamingApps,
|
|
|
|
|
[switch]$RemoveCommApps,
|
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,
|
2025-11-29 17:15:12 +01:00
|
|
|
[switch]$DisableGameBarIntegration,
|
2026-02-18 19:00:49 +01:00
|
|
|
[switch]$EnableWindowsSandbox,
|
|
|
|
|
[switch]$EnableWindowsSubsystemForLinux,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$DisableTelemetry,
|
2026-02-18 19:00:49 +01:00
|
|
|
[switch]$DisableSearchHistory,
|
2025-05-01 22:32:41 +01:00
|
|
|
[switch]$DisableFastStartup,
|
2026-02-04 13:59:10 +01:00
|
|
|
[switch]$DisableBitlockerAutoEncryption,
|
2025-08-19 23:24:28 +05:30
|
|
|
[switch]$DisableModernStandbyNetworking,
|
2026-03-07 20:29:08 +01:00
|
|
|
[switch]$DisableStorageSense,
|
2026-02-04 14:01:04 +01:00
|
|
|
[switch]$DisableUpdateASAP,
|
|
|
|
|
[switch]$PreventUpdateAutoReboot,
|
|
|
|
|
[switch]$DisableDeliveryOptimization,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$DisableBing,
|
2026-03-07 20:28:48 +01:00
|
|
|
[switch]$DisableStoreSearchSuggestions,
|
2026-03-07 18:32:06 +00:00
|
|
|
[switch]$DisableSearchHighlights,
|
2024-12-26 19:06:49 +01:00
|
|
|
[switch]$DisableDesktopSpotlight,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$DisableLockscreenTips,
|
|
|
|
|
[switch]$DisableSuggestions,
|
2026-02-18 20:53:53 +01:00
|
|
|
[switch]$DisableLocationServices,
|
2026-03-07 18:32:06 +00:00
|
|
|
[switch]$DisableFindMyDevice,
|
2025-08-16 01:36:00 +02:00
|
|
|
[switch]$DisableEdgeAds,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$DisableBraveBloat,
|
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,
|
2025-06-12 21:50:57 +02:00
|
|
|
[switch]$EnableDarkMode,
|
|
|
|
|
[switch]$DisableTransparency,
|
|
|
|
|
[switch]$DisableAnimations,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$TaskbarAlignLeft,
|
2025-09-27 14:34:01 +02:00
|
|
|
[switch]$CombineTaskbarAlways, [switch]$CombineTaskbarWhenFull, [switch]$CombineTaskbarNever,
|
2025-10-06 23:33:04 +02:00
|
|
|
[switch]$CombineMMTaskbarAlways, [switch]$CombineMMTaskbarWhenFull, [switch]$CombineMMTaskbarNever,
|
|
|
|
|
[switch]$MMTaskbarModeAll, [switch]$MMTaskbarModeMainActive, [switch]$MMTaskbarModeActive,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$HideSearchTb, [switch]$ShowSearchIconTb, [switch]$ShowSearchLabelTb, [switch]$ShowSearchBoxTb,
|
|
|
|
|
[switch]$HideTaskview,
|
2025-02-03 21:27:46 +01:00
|
|
|
[switch]$DisableStartRecommended,
|
2026-03-09 23:03:56 +01:00
|
|
|
[switch]$DisableStartAllApps,
|
2025-06-11 22:04:17 +02:00
|
|
|
[switch]$DisableStartPhoneLink,
|
2024-03-11 23:38:19 +01:00
|
|
|
[switch]$DisableCopilot,
|
2024-06-05 09:17:24 +02:00
|
|
|
[switch]$DisableRecall,
|
2025-09-17 23:33:52 +02:00
|
|
|
[switch]$DisableClickToDo,
|
2026-03-07 20:28:58 +01:00
|
|
|
[switch]$DisableAISvcAutoStart,
|
2025-08-01 21:21:38 +02:00
|
|
|
[switch]$DisablePaintAI,
|
|
|
|
|
[switch]$DisableNotepadAI,
|
2025-08-16 01:36:00 +02:00
|
|
|
[switch]$DisableEdgeAI,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$DisableWidgets,
|
|
|
|
|
[switch]$HideChat,
|
2025-04-16 12:31:18 +02:00
|
|
|
[switch]$EnableEndTask,
|
2025-07-30 15:30:51 -04:00
|
|
|
[switch]$EnableLastActiveClick,
|
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,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$DisableDragTray,
|
2025-02-13 21:08:47 +01:00
|
|
|
[switch]$DisableMouseAcceleration,
|
2025-04-16 12:56:37 +02:00
|
|
|
[switch]$DisableStickyKeys,
|
2026-02-12 23:14:15 +01:00
|
|
|
[switch]$DisableWindowSnapping,
|
|
|
|
|
[switch]$DisableSnapAssist,
|
|
|
|
|
[switch]$DisableSnapLayouts,
|
|
|
|
|
[switch]$HideTabsInAltTab, [switch]$Show3TabsInAltTab, [switch]$Show5TabsInAltTab, [switch]$Show20TabsInAltTab,
|
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,
|
2025-12-29 01:03:14 +01:00
|
|
|
[switch]$AddFoldersToThisPC,
|
2026-02-01 01:41:12 +01:00
|
|
|
[switch]$HideOnedrive,
|
|
|
|
|
[switch]$Hide3dObjects,
|
|
|
|
|
[switch]$HideMusic,
|
|
|
|
|
[switch]$HideIncludeInLibrary,
|
|
|
|
|
[switch]$HideGiveAccessTo,
|
|
|
|
|
[switch]$HideShare
|
2020-11-07 02:57:38 +01:00
|
|
|
)
|
|
|
|
|
|
2023-08-03 22:24:27 +02:00
|
|
|
|
2025-12-15 23:22:29 +01:00
|
|
|
|
2025-12-26 20:36:51 +01:00
|
|
|
# Define script-level variables & paths
|
2026-03-15 22:59:37 +01:00
|
|
|
$script:Version = "2026.03.15"
|
2026-03-08 01:34:53 +01:00
|
|
|
$script:AppsListFilePath = "$PSScriptRoot/Config/Apps.json"
|
|
|
|
|
$script:DefaultSettingsFilePath = "$PSScriptRoot/Config/DefaultSettings.json"
|
|
|
|
|
$script:FeaturesFilePath = "$PSScriptRoot/Config/Features.json"
|
|
|
|
|
$script:SavedSettingsFilePath = "$PSScriptRoot/Config/LastUsedSettings.json"
|
|
|
|
|
$script:CustomAppsListFilePath = "$PSScriptRoot/Config/CustomAppsList"
|
2026-02-15 23:08:54 +01:00
|
|
|
$script:DefaultLogPath = "$PSScriptRoot/Logs/Win11Debloat.log"
|
2025-12-26 20:36:51 +01:00
|
|
|
$script:RegfilesPath = "$PSScriptRoot/Regfiles"
|
|
|
|
|
$script:AssetsPath = "$PSScriptRoot/Assets"
|
2026-02-15 23:08:54 +01:00
|
|
|
$script:AppSelectionSchema = "$PSScriptRoot/Schemas/AppSelectionWindow.xaml"
|
|
|
|
|
$script:MainWindowSchema = "$PSScriptRoot/Schemas/MainWindow.xaml"
|
|
|
|
|
$script:MessageBoxSchema = "$PSScriptRoot/Schemas/MessageBoxWindow.xaml"
|
|
|
|
|
$script:AboutWindowSchema = "$PSScriptRoot/Schemas/AboutWindow.xaml"
|
2026-03-07 14:49:29 +01:00
|
|
|
$script:ApplyChangesWindowSchema = "$PSScriptRoot/Schemas/ApplyChangesWindow.xaml"
|
2026-03-22 22:07:51 +01:00
|
|
|
$script:RevertSettingsWindowSchema = "$PSScriptRoot/Schemas/RevertSettingsWindow.xaml"
|
2026-03-07 14:49:29 +01:00
|
|
|
$script:SharedStylesSchema = "$PSScriptRoot/Schemas/SharedStyles.xaml"
|
2026-03-15 20:16:53 +01:00
|
|
|
$script:BubbleHintSchema = "$PSScriptRoot/Schemas/BubbleHint.xaml"
|
2026-03-15 22:58:06 +01:00
|
|
|
$script:LoadAppsDetailsScriptPath = "$PSScriptRoot/Scripts/FileIO/LoadAppsDetailsFromJson.ps1"
|
2025-12-26 20:36:51 +01:00
|
|
|
|
2026-03-22 22:07:51 +01:00
|
|
|
$script:ControlParams = 'WhatIf', 'Confirm', 'Verbose', 'Debug', 'LogPath', 'Silent', 'Undo', 'Sysprep', 'User', 'NoRestartExplorer', 'RunDefaults', 'RunDefaultsLite', 'RunSavedSettings', 'RunAppsListGenerator', 'CLI', 'AppRemovalTarget'
|
2026-02-01 01:41:12 +01:00
|
|
|
|
|
|
|
|
# Script-level variables for GUI elements
|
|
|
|
|
$script:GuiWindow = $null
|
2026-02-06 23:44:39 +01:00
|
|
|
$script:CancelRequested = $false
|
2026-03-07 14:49:29 +01:00
|
|
|
$script:ApplyProgressCallback = $null
|
|
|
|
|
$script:ApplySubStepCallback = $null
|
2025-12-26 20:36:51 +01:00
|
|
|
|
|
|
|
|
# Check if current powershell environment is limited by security policies
|
2024-06-26 20:27:25 +02:00
|
|
|
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
|
2025-12-26 20:36:51 +01:00
|
|
|
Write-Error "Win11Debloat is unable to run on your system, powershell execution is restricted by security policies"
|
|
|
|
|
Write-Output "Press any key to exit..."
|
|
|
|
|
$null = [System.Console]::ReadKey()
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-01 01:41:12 +01:00
|
|
|
# Display ASCII art launch logo in CLI
|
|
|
|
|
Clear-Host
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " ^" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " / \" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " / \" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " / \" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " / ===== \" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " |" -ForegroundColor Blue -NoNewline; Write-Host " --- " -ForegroundColor White -NoNewline; Write-Host "|" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " |" -ForegroundColor Blue -NoNewline; Write-Host " ( O ) " -ForegroundColor DarkCyan -NoNewline; Write-Host "|" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " |" -ForegroundColor Blue -NoNewline; Write-Host " --- " -ForegroundColor White -NoNewline; Write-Host "|" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " | |" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " /| |\" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host "/ | | \" -ForegroundColor Blue
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " | " -ForegroundColor DarkGray -NoNewline; Write-Host "'''" -ForegroundColor Red -NoNewline; Write-Host " |" -ForegroundColor DarkGray -NoNewline; Write-Host " *" -ForegroundColor Yellow
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " (" -ForegroundColor Yellow -NoNewline; Write-Host "'''" -ForegroundColor Red -NoNewline; Write-Host ") " -ForegroundColor Yellow -NoNewline; Write-Host " * *" -ForegroundColor DarkYellow
|
|
|
|
|
Write-Host " " -NoNewline; Write-Host " ( " -ForegroundColor DarkYellow -NoNewline; Write-Host "'" -ForegroundColor Red -NoNewline; Write-Host " ) " -ForegroundColor DarkYellow -NoNewline; Write-Host "*" -ForegroundColor Yellow
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host " Win11Debloat is launching..." -ForegroundColor White
|
|
|
|
|
Write-Host " Leave this window open" -ForegroundColor DarkGray
|
|
|
|
|
Write-Host ""
|
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
|
2025-05-25 20:25:06 +02:00
|
|
|
if ($LogPath -and (Test-Path $LogPath)) {
|
2025-05-10 13:02:48 +02:00
|
|
|
Start-Transcript -Path "$LogPath/Win11Debloat.log" -Append -IncludeInvocationHeader -Force | Out-Null
|
|
|
|
|
}
|
|
|
|
|
else {
|
2025-12-26 20:36:51 +01:00
|
|
|
Start-Transcript -Path $script:DefaultLogPath -Append -IncludeInvocationHeader -Force | Out-Null
|
2025-05-10 13:02:48 +02:00
|
|
|
}
|
2024-06-26 20:27:25 +02:00
|
|
|
|
2026-03-22 22:07:51 +01:00
|
|
|
# Check if script has all required files/directories.
|
|
|
|
|
$optionalPathVariables = @('SavedSettingsFilePath', 'CustomAppsListFilePath', 'DefaultLogPath')
|
|
|
|
|
$requiredPathVariables = @(Get-Variable -Scope Script | Where-Object {
|
2026-03-22 23:48:56 +01:00
|
|
|
$_.Name -match '(FilePath|Schema|ScriptPath|RegfilesPath|AssetsPath)$' -and ($optionalPathVariables -notcontains $_.Name)
|
2026-03-22 22:07:51 +01:00
|
|
|
} | Select-Object -ExpandProperty Name)
|
|
|
|
|
|
|
|
|
|
$missingRequiredPaths = @()
|
|
|
|
|
foreach ($variableName in $requiredPathVariables) {
|
|
|
|
|
$pathValue = Get-Variable -Name $variableName -Scope Script -ValueOnly
|
|
|
|
|
|
|
|
|
|
if ([String]::IsNullOrWhiteSpace($pathValue) -or -not (Test-Path $pathValue)) {
|
|
|
|
|
$missingRequiredPaths += "$variableName => $pathValue"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($missingRequiredPaths.Count -gt 0) {
|
|
|
|
|
Write-Error "Win11Debloat is unable to find required files, please ensure all script files are present. Missing: $($missingRequiredPaths -join '; ')"
|
2026-02-01 01:41:12 +01:00
|
|
|
Write-Output ""
|
|
|
|
|
Write-Output "Press any key to exit..."
|
|
|
|
|
$null = [System.Console]::ReadKey()
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Load feature info from file
|
|
|
|
|
$script:Features = @{}
|
|
|
|
|
try {
|
|
|
|
|
$featuresData = Get-Content -Path $script:FeaturesFilePath -Raw | ConvertFrom-Json
|
|
|
|
|
foreach ($feature in $featuresData.Features) {
|
|
|
|
|
$script:Features[$feature.FeatureId] = $feature
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
Write-Error "Failed to load feature info from Features.json file"
|
|
|
|
|
Write-Output ""
|
|
|
|
|
Write-Output "Press any key to exit..."
|
|
|
|
|
$null = [System.Console]::ReadKey()
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check if WinGet is installed & if it is, check if the version is at least v1.4
|
|
|
|
|
try {
|
2026-02-19 22:44:50 +01:00
|
|
|
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
2026-02-01 01:41:12 +01:00
|
|
|
$script:WingetInstalled = $true
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$script:WingetInstalled = $false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch {
|
2026-02-19 22:44:50 +01:00
|
|
|
Write-Error "Unable to determine if WinGet is installed, winget command failed: $_"
|
2026-02-01 01:41:12 +01:00
|
|
|
$script:WingetInstalled = $false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show WinGet warning that requires user confirmation, Suppress confirmation if Silent parameter was passed
|
|
|
|
|
if (-not $script:WingetInstalled -and -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..."
|
|
|
|
|
$null = [System.Console]::ReadKey()
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-15 23:22:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
##################################################################################################################
|
|
|
|
|
# #
|
2026-03-15 22:58:06 +01:00
|
|
|
# FUNCTION IMPORTS #
|
2025-12-15 23:22:29 +01:00
|
|
|
# #
|
|
|
|
|
##################################################################################################################
|
|
|
|
|
|
2026-03-15 22:58:06 +01:00
|
|
|
# App removal functions
|
2026-03-07 20:28:48 +01:00
|
|
|
. "$PSScriptRoot/Scripts/AppRemoval/ForceRemoveEdge.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/AppRemoval/RemoveApps.ps1"
|
2026-03-15 22:58:06 +01:00
|
|
|
. "$PSScriptRoot/Scripts/AppRemoval/GetInstalledAppsViaWinget.ps1"
|
2026-03-07 20:28:48 +01:00
|
|
|
|
2026-03-15 22:58:06 +01:00
|
|
|
# CLI functions
|
2026-03-07 20:28:48 +01:00
|
|
|
. "$PSScriptRoot/Scripts/CLI/AwaitKeyToExit.ps1"
|
2026-02-15 23:08:54 +01:00
|
|
|
. "$PSScriptRoot/Scripts/CLI/ShowCLILastUsedSettings.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/ShowCLIDefaultModeAppRemovalOptions.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/ShowCLIDefaultModeOptions.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/ShowCLIAppRemoval.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/ShowCLIMenuOptions.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/PrintPendingChanges.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/CLI/PrintHeader.ps1"
|
|
|
|
|
|
2026-03-15 22:58:06 +01:00
|
|
|
# Features functions
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/ExecuteChanges.ps1"
|
2026-03-07 20:28:48 +01:00
|
|
|
. "$PSScriptRoot/Scripts/Features/CreateSystemRestorePoint.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/DisableStoreSearchSuggestions.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/EnableWindowsFeature.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/ImportRegistryFile.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/ReplaceStartMenu.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Features/RestartExplorer.ps1"
|
|
|
|
|
|
2026-03-15 22:58:06 +01:00
|
|
|
# File I/O functions
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/LoadJsonFile.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/SaveSettings.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/LoadSettings.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/SaveCustomAppsListToFile.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/ValidateAppslist.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/LoadAppsFromFile.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/LoadAppsDetailsFromJson.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/FileIO/LoadAppPresetsFromJson.ps1"
|
|
|
|
|
|
|
|
|
|
# GUI functions
|
2026-02-15 23:08:54 +01:00
|
|
|
. "$PSScriptRoot/Scripts/GUI/GetSystemUsesDarkMode.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/SetWindowThemeResources.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/AttachShiftClickBehavior.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/ApplySettingsToUiControls.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-MessageBox.ps1"
|
2026-03-07 14:49:29 +01:00
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-ApplyModal.ps1"
|
2026-03-22 22:07:51 +01:00
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-RevertSettingsModal.ps1"
|
2026-02-15 23:08:54 +01:00
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-AppSelectionWindow.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-MainWindow.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-AboutDialog.ps1"
|
2026-03-15 20:16:53 +01:00
|
|
|
. "$PSScriptRoot/Scripts/GUI/Show-Bubble.ps1"
|
2026-02-15 23:08:54 +01:00
|
|
|
|
2026-03-15 22:58:06 +01:00
|
|
|
# Helper functions
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/AddParameter.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/CheckIfUserExists.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/CheckModernStandbySupport.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GenerateAppsList.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GetFriendlyTargetUserName.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GetTargetUserForAppRemoval.ps1"
|
2026-03-22 22:07:51 +01:00
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GetUndoFeatureForParam.ps1"
|
2026-03-15 22:58:06 +01:00
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GetUserDirectory.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Helpers/GetUserName.ps1"
|
2026-03-18 22:39:49 +01:00
|
|
|
. "$PSScriptRoot/Scripts/Helpers/TestIfUserIsLoggedIn.ps1"
|
2026-03-15 22:58:06 +01:00
|
|
|
|
|
|
|
|
# Threading functions
|
|
|
|
|
. "$PSScriptRoot/Scripts/Threading/DoEvents.ps1"
|
|
|
|
|
. "$PSScriptRoot/Scripts/Threading/Invoke-NonBlocking.ps1"
|
2025-02-13 21:08:47 +01:00
|
|
|
|
|
|
|
|
|
2024-06-27 23:08:43 +02:00
|
|
|
|
|
|
|
|
##################################################################################################################
|
|
|
|
|
# #
|
|
|
|
|
# SCRIPT START #
|
|
|
|
|
# #
|
|
|
|
|
##################################################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-02-01 01:41:12 +01:00
|
|
|
# Get current Windows build version
|
2024-06-27 23:08:43 +02:00
|
|
|
$WinVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' CurrentBuild
|
|
|
|
|
|
2025-08-22 17:50:47 +02:00
|
|
|
# Check if the machine supports Modern Standby, this is used to determine if the DisableModernStandbyNetworking option can be used
|
|
|
|
|
$script:ModernStandbySupported = CheckModernStandbySupport
|
2025-08-19 23:24:28 +05:30
|
|
|
|
2025-05-10 13:02:48 +02:00
|
|
|
$script:Params = $PSBoundParameters
|
2023-09-27 21:03:25 +02:00
|
|
|
|
2025-12-26 20:36:51 +01:00
|
|
|
# Add default Apps parameter when RemoveApps is requested and Apps was not explicitly provided
|
|
|
|
|
if ((-not $script:Params.ContainsKey("Apps")) -and $script:Params.ContainsKey("RemoveApps")) {
|
|
|
|
|
$script:Params.Add('Apps', 'Default')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$controlParamsCount = 0
|
|
|
|
|
|
|
|
|
|
# Count how many control parameters are set, to determine if any changes were selected by the user during runtime
|
|
|
|
|
foreach ($Param in $script:ControlParams) {
|
2025-05-10 13:02:48 +02:00
|
|
|
if ($script:Params.ContainsKey($Param)) {
|
2025-12-26 20:36:51 +01:00
|
|
|
$controlParamsCount++
|
2023-09-27 21:03:25 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-22 22:07:51 +01:00
|
|
|
# Guard: Undo mode requires at least one actionable, non-control parameter.
|
|
|
|
|
if ($script:Params.ContainsKey('Undo')) {
|
2026-03-22 23:44:59 +01:00
|
|
|
$loadsSettingsFromPreset = $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings
|
2026-03-22 22:07:51 +01:00
|
|
|
$undoTargets = @($script:Params.Keys | Where-Object {
|
|
|
|
|
($script:ControlParams -notcontains $_) -and $_ -ne 'Apps' -and $_ -ne 'CreateRestorePoint'
|
|
|
|
|
})
|
|
|
|
|
|
2026-03-22 23:44:59 +01:00
|
|
|
if ($undoTargets.Count -eq 0 -and -not $loadsSettingsFromPreset) {
|
2026-03-22 22:07:51 +01:00
|
|
|
Write-Error "The -Undo parameter requires at least one setting/feature parameter to revert."
|
|
|
|
|
AwaitKeyToExit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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-05-10 13:02:48 +02:00
|
|
|
if ($script:Params.ContainsKey("Sysprep")) {
|
2025-09-07 15:04:29 +02:00
|
|
|
$defaultUserPath = GetUserDirectory -userName "Default"
|
2024-08-31 22:13:59 +02:00
|
|
|
|
2024-06-27 23:08:43 +02:00
|
|
|
# Exit script if run in Sysprep mode on Windows 10
|
|
|
|
|
if ($WinVersion -lt 22000) {
|
2025-12-26 20:36:51 +01:00
|
|
|
Write-Error "Win11Debloat Sysprep mode is not supported on Windows 10"
|
2024-06-27 23:08:43 +02:00
|
|
|
AwaitKeyToExit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-12 22:50:22 +01:00
|
|
|
# Ensure that target user exists, if User or AppRemovalTarget parameter was provided
|
2025-05-10 13:02:48 +02:00
|
|
|
if ($script:Params.ContainsKey("User")) {
|
2025-09-07 15:04:29 +02:00
|
|
|
$userPath = GetUserDirectory -userName $script:Params.Item("User")
|
2025-03-05 23:39:29 +01:00
|
|
|
}
|
2026-02-12 22:50:22 +01:00
|
|
|
if ($script:Params.ContainsKey("AppRemovalTarget")) {
|
|
|
|
|
$userPath = GetUserDirectory -userName $script:Params.Item("AppRemovalTarget")
|
|
|
|
|
}
|
2025-03-05 23:39:29 +01:00
|
|
|
|
2025-12-26 20:36:51 +01:00
|
|
|
# Remove LastUsedSettings.json file if it exists and is empty
|
|
|
|
|
if ((Test-Path $script:SavedSettingsFilePath) -and ([String]::IsNullOrWhiteSpace((Get-content $script:SavedSettingsFilePath)))) {
|
|
|
|
|
Remove-Item -Path $script:SavedSettingsFilePath -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
|
2026-02-01 01:41:12 +01:00
|
|
|
if ($RunAppsListGenerator) {
|
2025-04-19 15:16:47 +02:00
|
|
|
PrintHeader "Custom Apps List Generator"
|
2024-03-11 23:38:19 +01:00
|
|
|
|
2026-02-15 23:08:54 +01:00
|
|
|
$result = Show-AppSelectionWindow
|
2024-03-29 16:56:29 +01:00
|
|
|
|
2024-03-11 23:38:19 +01:00
|
|
|
# Show different message based on whether the app selection was saved or cancelled
|
2026-02-01 01:41:12 +01:00
|
|
|
if ($result -ne $true) {
|
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-12-26 20:36:51 +01:00
|
|
|
if ((-not $script:Params.Count) -or $RunDefaults -or $RunDefaultsLite -or $RunSavedSettings -or ($controlParamsCount -eq $script:Params.Count)) {
|
2025-09-13 23:36:38 +02:00
|
|
|
if ($RunDefaults -or $RunDefaultsLite) {
|
2026-02-15 23:08:54 +01:00
|
|
|
ShowCLIDefaultModeOptions
|
2020-11-07 02:57:38 +01:00
|
|
|
}
|
2025-01-09 21:33:28 +01:00
|
|
|
elseif ($RunSavedSettings) {
|
2025-12-26 20:36:51 +01:00
|
|
|
if (-not (Test-Path $script:SavedSettingsFilePath)) {
|
2025-01-09 21:33:28 +01:00
|
|
|
PrintHeader 'Custom Mode'
|
2025-12-26 20:36:51 +01:00
|
|
|
Write-Error "Unable to find LastUsedSettings.json file, no changes were made"
|
2025-01-09 21:33:28 +01:00
|
|
|
AwaitKeyToExit
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 23:08:54 +01:00
|
|
|
ShowCLILastUsedSettings
|
2025-01-09 21:33:28 +01:00
|
|
|
}
|
2023-05-15 16:38:11 -06:00
|
|
|
else {
|
2026-02-01 01:41:12 +01:00
|
|
|
if ($CLI) {
|
2026-02-15 23:08:54 +01:00
|
|
|
$Mode = ShowCLIMenuOptions
|
2026-02-01 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
try {
|
2026-02-15 23:08:54 +01:00
|
|
|
$result = Show-MainWindow
|
2026-02-01 01:41:12 +01:00
|
|
|
|
|
|
|
|
Stop-Transcript
|
|
|
|
|
Exit
|
|
|
|
|
}
|
|
|
|
|
catch {
|
2026-03-22 22:07:51 +01:00
|
|
|
Write-Warning "Something went wrong while loading the graphical interface, falling back to CLI mode: $_"
|
2026-02-01 13:12:32 +01:00
|
|
|
if (-not $Silent) {
|
|
|
|
|
Write-Host ""
|
|
|
|
|
Write-Host "Press any key to continue..."
|
|
|
|
|
$null = [System.Console]::ReadKey()
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-15 23:08:54 +01:00
|
|
|
$Mode = ShowCLIMenuOptions
|
2026-02-01 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
}
|
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) {
|
2025-12-15 23:22:29 +01:00
|
|
|
# Default mode, loads defaults and app removal options
|
2023-05-15 16:38:11 -06:00
|
|
|
'1' {
|
2026-02-15 23:08:54 +01:00
|
|
|
ShowCLIDefaultModeOptions
|
2021-12-15 21:45:48 +01:00
|
|
|
}
|
2022-09-08 17:20:53 +02:00
|
|
|
|
2024-03-29 16:56:29 +01:00
|
|
|
# App removal, remove apps based on user selection
|
2026-02-01 01:41:12 +01:00
|
|
|
'2' {
|
2026-02-15 23:08:54 +01:00
|
|
|
ShowCLIAppRemoval
|
2024-03-29 16:56:29 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-26 20:36:51 +01:00
|
|
|
# Load last used options from the "LastUsedSettings.json" file
|
2026-02-01 01:41:12 +01:00
|
|
|
'3' {
|
2026-02-15 23:08:54 +01:00
|
|
|
ShowCLILastUsedSettings
|
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 {
|
2026-02-01 01:41:12 +01:00
|
|
|
PrintHeader 'Configuration'
|
2020-11-06 12:48:13 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-26 20:36:51 +01:00
|
|
|
# If the number of keys in ControlParams equals the number of keys in Params then no modifications/changes were selected
|
2024-03-01 13:54:02 +01:00
|
|
|
# or added by the user, and the script can exit without making any changes.
|
2025-12-26 20:36:51 +01:00
|
|
|
if (($controlParamsCount -eq $script:Params.Keys.Count) -or ($script:Params.Keys.Count -eq 1 -and ($script:Params.Keys -contains 'CreateRestorePoint' -or $script:Params.Keys -contains 'Apps'))) {
|
2023-09-28 16:11:04 +02:00
|
|
|
Write-Output "The script completed without making any changes."
|
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
|
|
|
|
2026-03-23 20:47:46 +01:00
|
|
|
try {
|
|
|
|
|
# Execute all selected/provided parameters using the consolidated function
|
|
|
|
|
# (This also handles restore point creation if requested)
|
|
|
|
|
ExecuteAllChanges
|
|
|
|
|
}
|
|
|
|
|
catch {
|
|
|
|
|
Write-Error "An error occurred while applying changes: $_"
|
|
|
|
|
|
|
|
|
|
AwaitKeyToExit
|
|
|
|
|
}
|
|
|
|
|
|
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
|