Add parameter option to run script with the Saved Custom Settings #176

This commit is contained in:
Raphire
2025-01-09 21:33:28 +01:00
parent 8a27bc9a05
commit 0b967ff137
4 changed files with 48 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ param (
[switch]$Sysprep,
[switch]$RunAppConfigurator,
[switch]$RunDefaults, [switch]$RunWin11Defaults,
[switch]$RunSavedSettings,
[switch]$RemoveApps,
[switch]$RemoveAppsCustom,
[switch]$RemoveGamingApps,

View File

@@ -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.
-------------------------------------------------------------------------------------------

View File

@@ -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. |

View File

@@ -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()
# 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('#'))
# 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
}
if (-not $global:Params.ContainsKey($parameterName)){
$global:Params.Add($parameterName, $true)
}
$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 $Silent) {
Write-Output ""
Write-Output ""
Write-Output "Press enter to execute the script or press CTRL+C to quit..."