How to Use Win11Debloat's Custom Settings Persistence to Automate Windows Tweaks
Win11Debloat saves your configuration to Config/LastUsedSettings.json and restores it via the -RunSavedSettings switch, letting you re-apply previous tweaks without reselecting options.
Win11Debloat, the popular open-source PowerShell script from Raphire/Win11Debloat, includes a robust custom settings persistence feature that remembers your preferred Windows debloating configuration between executions. Instead of manually selecting the same checkboxes or typing identical parameters every time, you can serialize your setup once and redeploy it instantly. This automation is handled through a JSON-based storage system located in the script's Config/ directory.
How the Settings Persistence Mechanism Works
The persistence system relies on two core functions in the Scripts/FileIO/ directory: SaveSettings and LoadSettings. According to the Win11Debloat source code, the workflow follows four distinct stages:
- Save: After any run completes, the
SaveSettingsfunction inScripts/FileIO/SaveSettings.ps1serializes your selected feature parameters intoConfig/LastUsedSettings.json. - Load: When you invoke
-RunSavedSettingsor select the CLI menu option,LoadSettingsinScripts/FileIO/LoadSettings.ps1reads the JSON, validates the schema version, and injects values back into$script:Params. - Apply: The main script
Win11Debloat.ps1executesExecuteAllChangesusing the restored parameters. - UI Hook: For CLI users,
Scripts/CLI/ShowCLILastUsedSettings.ps1provides a summary screen before applying changes.
What Gets Stored in LastUsedSettings.json
The configuration file uses a fixed JSON schema version 1.0 and resides at Config/LastUsedSettings.json relative to the script root.
Only feature parameters—such as DisableTelemetry, EnableWindowsSandbox, or RemoveApps—are persisted. Control switches like -Verbose, -Silent, or -Sysprep are intentionally excluded from the save operation.
If the JSON file becomes corrupted or empty, the script automatically deletes it during initialization (see lines 782-785 in Win11Debloat.ps1).
Saving Your Configuration Automatically
You don't need a dedicated "save" command. The SaveSettings function triggers automatically at the end of every execution, whether you use the GUI or CLI.
When you run:
.\Win11Debloat.ps1 -DisableTelemetry -RemoveApps -EnableDarkMode
The script creates or overwrites Config/LastUsedSettings.json with a structure resembling:
{
"Version": "1.0",
"Settings": [
{ "Name": "DisableTelemetry", "Value": true },
{ "Name": "RemoveApps", "Value": true },
{ "Name": "EnableDarkMode", "Value": true }
]
}
Restoring Saved Settings with -RunSavedSettings
To reuse a previously saved configuration, pass the -RunSavedSettings switch:
.\Win11Debloat.ps1 -RunSavedSettings
This bypasses the selection UI and immediately applies all stored tweaks. Alternatively, launch the CLI menu and choose option 3 – Load last used settings, which invokes ShowCLILastUsedSettings.ps1 to display a preview before execution.
The LoadSettings function validates that the JSON version matches the expected schema (currently 1.0) before populating $script:Params.
Manual Inspection and Troubleshooting
You can verify your saved configuration by reading the JSON file directly:
Get-Content ".\Config\LastUsedSettings.json" | ConvertFrom-Json
If you encounter issues loading settings, check that the file exists and contains valid JSON. As implemented in Win11Debloat.ps1, the script removes empty or corrupted settings files automatically to prevent execution errors.
Summary
- Win11Debloat saves configurations to
Config/LastUsedSettings.jsonvia theSaveSettingsfunction inScripts/FileIO/SaveSettings.ps1. - Use the
-RunSavedSettingsswitch or CLI menu option 3 to restore settings throughScripts/FileIO/LoadSettings.ps1. - Only feature parameters are persisted; control switches like
-Silentare excluded. - The JSON schema is fixed at version 1.0 and validated during load operations.
- Corrupted files are automatically purged by
Win11Debloat.ps1(lines 782-785).
Frequently Asked Questions
What file format does Win11Debloat use for settings persistence?
Win11Debloat uses a JSON file named LastUsedSettings.json stored in the Config/ directory. The file follows a strict schema versioned at 1.0 and contains an array of setting objects with Name and Value properties.
Does Win11Debloat save all command-line switches?
No. According to the implementation in Scripts/FileIO/SaveSettings.ps1, only feature-related parameters (like DisableTelemetry or RemoveApps) are persisted. Control switches such as -Verbose, -Silent, or -Sysprep are deliberately excluded from the JSON output.
How do I restore my previous Win11Debloat configuration?
Run .\Win11Debloat.ps1 -RunSavedSettings to load and apply the settings from Config/LastUsedSettings.json without opening the selection interface. You can also launch the script with -CLI and select option 3 from the menu to preview changes before applying them via Scripts/CLI/ShowCLILastUsedSettings.ps1.
What happens if the LastUsedSettings.json file is corrupted?
The main script Win11Debloat.ps1 detects corrupted or empty JSON files during initialization (specifically around lines 782-785) and automatically deletes them to prevent runtime errors. You will need to reconfigure and save your settings again.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →