From 0b967ff137c51005f8b35e4d7758579d02f1ea10 Mon Sep 17 00:00:00 2001 From: Raphire <9938813+Raphire@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:33:28 +0100 Subject: [PATCH] Add parameter option to run script with the Saved Custom Settings #176 --- Get.ps1 | 1 + Menus/Info | 13 +++++---- README.md | 1 + Win11Debloat.ps1 | 70 +++++++++++++++++++++++++++--------------------- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/Get.ps1 b/Get.ps1 index bac9b15..497bb64 100644 --- a/Get.ps1 +++ b/Get.ps1 @@ -4,6 +4,7 @@ param ( [switch]$Sysprep, [switch]$RunAppConfigurator, [switch]$RunDefaults, [switch]$RunWin11Defaults, + [switch]$RunSavedSettings, [switch]$RemoveApps, [switch]$RemoveAppsCustom, [switch]$RemoveGamingApps, diff --git a/Menus/Info b/Menus/Info index 78236a7..24ce3b7 100644 --- a/Menus/Info +++ b/Menus/Info @@ -11,23 +11,24 @@ all the settings yourself, or remove apps one by one. ------------------------------------------------------------------------------------------- App Removal - Remove a wide variety of bloatware apps. -- Remove all pinned apps from start for the current user, or for all new & existing users. (Windows 11 only) +- Remove all pinned apps from start for the current user, or for all existing & new users. (Windows 11 only) Telemetry, Tracking & Suggested Content - Disable telemetry, diagnostic data, activity history, app-launch tracking & targeted ads. - Disable tips, tricks, suggestions & ads across Windows. +- Disable the 'Windows Spotlight' desktop background option. Bing, Copilot & More - Disable & remove Bing web search & Cortana from Windows search. -- Disable Windows Copilot. (Windows 11 only) +- Disable & remove Windows Copilot. (Windows 11 only) - Disable Windows Recall snapshots. (Windows 11 only) File Explorer - Change the default location that File Explorer opens to. - Show hidden files, folders & drives. - Show file extensions for known file types. -- Hide the gallery section from the File Explorer sidepanel. (Windows 11 only) -- Hide the 3D objects, music or onedrive folder from the File Explorer sidepanel. (Windows 10 only) +- Hide the Home or Gallery section from the File Explorer navigation pane. (Windows 11 only) +- Hide the 3D objects, music or OneDrive folder from the File Explorer sidepanel. (Windows 10 only) - Hide duplicate removable drive entries from the File Explorer sidepanel. Taskbar @@ -42,9 +43,7 @@ Context menu - Hide the 'Include in library', 'Give access to' & 'Share' options from the context menu. (Windows 10 only) Other -- Disable Xbox game/screen recording (Also stops gaming overlay popups) - -Advanced Features +- Disable Xbox game/screen recording. (Also stops gaming overlay popups) - Sysprep mode to apply changes to the Windows Default user profile. ------------------------------------------------------------------------------------------- diff --git a/README.md b/README.md index d4c03dd..1e0585c 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,7 @@ The quick and advanced usage methods support switch parameters. A table of all t | -Silent | Suppresses all interactive prompts, so the script will run without requiring any user input. | | -Sysprep | Run the script in Sysprep mode. All changes will be applied to the Windows default user profile and will only affect new user accounts. | | -RunDefaults | Run the script with the default settings. | +| -RunSavedSettings | Run the script with the saved custom settings from last time. These settings are saved to and read from the `SavedSettings` file in the root folder of the script. | | -RemoveApps | Remove the default selection of bloatware apps. | | -RemoveAppsCustom | Remove all apps specified in the 'CustomAppsList' file. IMPORTANT: You can generate your custom list by running the script with the `-RunAppConfigurator` parameter. No apps will be removed if this file does not exist! | | -RunAppConfigurator | Run the app configurator to generate a list of apps to remove, the list is saved to the 'CustomAppsList' file. Running the script with the `-RemoveAppsCustom` parameter will remove the selected apps. | diff --git a/Win11Debloat.ps1 b/Win11Debloat.ps1 index 99f41b8..591e5f4 100644 --- a/Win11Debloat.ps1 +++ b/Win11Debloat.ps1 @@ -6,6 +6,7 @@ param ( [switch]$Sysprep, [switch]$RunAppConfigurator, [switch]$RunDefaults, [switch]$RunWin11Defaults, + [switch]$RunSavedSettings, [switch]$RemoveApps, [switch]$RemoveAppsCustom, [switch]$RemoveGamingApps, @@ -792,15 +793,24 @@ if ($RunAppConfigurator) { } AwaitKeyToExit - Exit } # Change script execution based on provided parameters or user input -if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPParamCount -eq $global:Params.Count)) { +if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or $RunSavedSettings -or ($SPParamCount -eq $global:Params.Count)) { if ($RunDefaults -or $RunWin11Defaults) { $Mode = '1' } + elseif ($RunSavedSettings) { + if(-not (Test-Path "$PSScriptRoot/SavedSettings")) { + PrintHeader 'Custom Mode' + Write-Host "Error: No saved settings found, no changes were made" -ForegroundColor Red + AwaitKeyToExit + Exit + } + + $Mode = '4' + } else { # Show menu and wait for user input, loops until valid input is provided Do { @@ -970,7 +980,7 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP Write-Output "" - if ($( Read-Host -Prompt "Disable tips, tricks, suggestions and ads in start, settings, notifications, explorer and lockscreen? (y/n)" ) -eq 'y') { + if ($( Read-Host -Prompt "Disable tips, tricks, suggestions and ads in start, settings, notifications, explorer, desktop and lockscreen? (y/n)" ) -eq 'y') { AddParameter 'DisableSuggestions' 'Disable tips, tricks, suggestions and ads in start, settings, notifications and File Explorer' AddParameter 'DisableDesktopSpotlight' 'Disable the Windows Spotlight desktop background option.' AddParameter 'DisableLockscreenTips' 'Disable tips & tricks on the lockscreen' @@ -1223,40 +1233,40 @@ if ((-not $global:Params.Count) -or $RunDefaults -or $RunWin11Defaults -or ($SPP # Load custom options selection from the "SavedSettings" file '4' { - if (-not $Silent) { - PrintHeader 'Custom Mode' - Write-Output "Win11Debloat will make the following changes:" + PrintHeader 'Custom Mode' + Write-Output "Win11Debloat will make the following changes:" - # Get & print default settings info from file - 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('#')) + # Get & print default settings info from file + 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 - } - - $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)) + # 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 } + + $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)) + } - if (-not $global:Params.ContainsKey($parameterName)){ - $global:Params.Add($parameterName, $true) - } + if (-not $global:Params.ContainsKey($parameterName)){ + $global:Params.Add($parameterName, $true) } } + } + if (-not $Silent) { Write-Output "" Write-Output "" Write-Output "Press enter to execute the script or press CTRL+C to quit..."