# How to Use Win11Debloat's Custom Settings Persistence to Automate Windows Tweaks

> Automate Windows tweaks easily with Win11Debloat's custom settings persistence. Learn to use the -RunSavedSettings switch to re-apply previous configurations effortlessly.

- Repository: [Jeffrey/Win11Debloat](https://github.com/Raphire/Win11Debloat)
- Tags: how-to-guide
- Published: 2026-03-10

---

**Win11Debloat saves your configuration to [`Config/LastUsedSettings.json`](https://github.com/Raphire/Win11Debloat/blob/main/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:

1. **Save**: After any run completes, the `SaveSettings` function in `Scripts/FileIO/SaveSettings.ps1` serializes your selected feature parameters into [`Config/LastUsedSettings.json`](https://github.com/Raphire/Win11Debloat/blob/main/Config/LastUsedSettings.json).
2. **Load**: When you invoke `-RunSavedSettings` or select the CLI menu option, `LoadSettings` in `Scripts/FileIO/LoadSettings.ps1` reads the JSON, validates the schema version, and injects values back into `$script:Params`.
3. **Apply**: The main script `Win11Debloat.ps1` executes `ExecuteAllChanges` using the restored parameters.
4. **UI Hook**: For CLI users, `Scripts/CLI/ShowCLILastUsedSettings.ps1` provides 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`](https://github.com/Raphire/Win11Debloat/blob/main/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:

```powershell
.\Win11Debloat.ps1 -DisableTelemetry -RemoveApps -EnableDarkMode

```

The script creates or overwrites [`Config/LastUsedSettings.json`](https://github.com/Raphire/Win11Debloat/blob/main/Config/LastUsedSettings.json) with a structure resembling:

```json
{
  "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:

```powershell
.\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:

```powershell
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.json`](https://github.com/Raphire/Win11Debloat/blob/main/Config/LastUsedSettings.json) via the `SaveSettings` function in `Scripts/FileIO/SaveSettings.ps1`.
- Use the `-RunSavedSettings` switch or CLI menu option 3 to restore settings through `Scripts/FileIO/LoadSettings.ps1`.
- Only feature parameters are persisted; control switches like `-Silent` are 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`](https://github.com/Raphire/Win11Debloat/blob/main/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`](https://github.com/Raphire/Win11Debloat/blob/main/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.