How raphire/win11debloat works
1. Repository purpose
- This is a Windows 11 “debloat/customization” tool implemented as a PowerShell application, not a service or web app.
- Its job is to apply a curated set of OS changes: remove apps, change registry-backed UI/system settings, disable features, and optionally reverse those changes.
2. Entry points and runtime boundary
- Win11Debloat.ps1 is the primary script entry point.
- Run.bat is a convenience launcher for users who double-click the repo on Windows.
- The whole system runs locally on Windows and relies on PowerShell plus Windows administrative privileges for most operations.
3. Top-level orchestration flow
- The main script coordinates startup, option parsing, UI/CLI selection, loading saved settings, and then dispatches to either GUI-driven or CLI-driven execution paths.
- The architecture is centered around “collect user choices → resolve changes → execute changes → persist/update state”.
4. User interaction layer
- Scripts/GUI contains the WPF UI logic and window controllers.
- Schemas/*.xaml defines the actual windows and shared styles: main window, config window, app selection, apply modal, about dialog, message box, and bubble hint.
- Scripts/CLI contains the text-mode menu and status output for non-GUI usage.
- These are separate front ends over the same underlying change-execution engine.
5. Configuration and state
- Config/DefaultSettings.json provides the default preset.
- Config/Apps.json and Scripts/FileIO/LoadAppsDetailsFromJson.ps1 describe app metadata and removal candidates.
- Config/Features.json appears to define feature toggles and mapping data.
- Scripts/FileIO handles reading/writing settings, app lists, custom app presets, and validation.
- This is the main persistence boundary: user choices are stored outside the code in JSON/files so the same engine can be reused across UI, CLI, and sysprep modes.
6. Registry-based system changes
- Regfiles/ is the primary payload for Windows configuration changes.
- These .reg files are the actual implementation for many tweaks such as telemetry, taskbar, Explorer, search, start menu, AI features, update behavior, and privacy settings.
- Scripts/Features/ImportRegistryFile.ps1 is the bridge from PowerShell into the registry payloads.
- The presence of Undo/ and Sysprep/ variants shows three important state sets: current-user normal mode, rollback mode, and default-user/profile-prep mode.
7. Execution engine for feature changes
- Scripts/Features/ExecuteChanges.ps1 is the likely central executor that applies the selected settings.
- Supporting scripts handle system-level side effects such as creating restore points, restarting Explorer, enabling Windows features, disabling Store search suggestions, and replacing the Start menu.
- This layer is the boundary between selection and mutation: it turns abstract feature flags into concrete OS changes.
8. App removal subsystem
- Scripts/AppRemoval isolates uninstall logic from registry tweaks.
- GetInstalledAppsViaWinget.ps1 suggests detection uses Windows Package Manager metadata where available.
- RemoveApps.ps1 performs removals, and ForceRemoveEdge.ps1 handles a special-case browser removal path.
- App removal is therefore a separate subsystem from “feature toggles,” because it deals with package inventory and uninstall behavior instead of registry state.
9. Operating-context helpers
- Scripts/Helpers contains environment and identity logic: determining the target user, checking whether a user exists or is logged in, resolving user directories, and generating app lists.
- This is important because the tool supports applying changes to:
- the current logged-in user,
- another user profile,
- Windows Audit/Sysprep scenarios.
- These helpers form the boundary that adapts the tool to different Windows user/profile contexts.
10. Threading and responsiveness
- Scripts/Threading contains DoEvents.ps1 and Invoke-NonBlocking.ps1, which indicate the GUI path is designed to stay responsive while long-running changes are applied.
- This suggests long operations are executed asynchronously or cooperatively so the UI can show progress/modals without freezing.
11. Assets and UX support
- Assets/Images and Assets/Start provide bundled images and startup artifacts used by the UI/launcher experience.
- These are presentation-only assets; they do not affect the OS-tweak logic but support branding and the initial loading experience.
12. Packaging of reversible and specialized presets
- The duplicated .reg files under Regfiles/Sysprep and Regfiles/Undo show that the repo intentionally models multiple operation modes:
- standard apply,
- rollback/undo,
- default-profile preparation for new users.
- That structure is a major architecture clue: the tool is not a one-way cleaner, but a reversible policy application system.
13. External dependencies and system integration
- The main external dependency is the Windows OS itself: registry, Explorer, system features, optional Windows components, and installed app inventory.
- winget is used where available for app discovery/removal.
- The repo does not appear to rely on cloud services at runtime; the only networked path described in the README is the optional script download URL for bootstrap convenience.
14. How the pieces fit together
- Startup begins in the launcher/script entry point.
- Settings and app definitions are loaded from JSON.
- The user chooses options through GUI or CLI.
- The tool resolves the target user/context and translates selections into registry imports, package removals, and feature toggles.
- Supporting actions like restore-point creation and Explorer restart are executed as needed.
- Final settings/state may be saved for later reuse or reapplication.
Main entry points: Win11Debloat.ps1 Win11Debloat.ps1 · MainWindow.xaml Main window · LoadSettings.ps1 File I/O · ExecuteChanges.ps1 Execute changes
Components 21
Entry & runtime
Launch points and top-level orchestration
- Win11Debloat.ps1 · Primary PowerShell entry script that orchestrates mode selection and execution
Win11Debloat.ps1 - Run.bat · Windows batch launcher for double-click startup
Run.bat
User interface
GUI and CLI front ends
- Main window · Primary GUI window and overall application shell
Schemas/MainWindow.xaml - Config window · Window for editing and importing/exporting settings
Schemas/ImportExportConfigWindow.xaml - App picker · GUI for selecting apps and app-removal options
Schemas/AppSelectionWindow.xaml - Apply modal · Modal used while settings are being applied
Schemas/ApplyChangesWindow.xaml - CLI menus · Console menus, headers, and status output for non-GUI usage
Scripts/CLI/ShowCLIMenuOptions.ps1
Config & state
JSON presets, persistence, and import/export
- Default settings · Default preset and baseline configuration data
Config/DefaultSettings.json - Apps catalog · App metadata and removal candidates
Config/Apps.json - Features map · Feature toggle definitions and mapping data
Config/Features.json - File I/O · Loads, saves, validates, and imports settings and app lists
Scripts/FileIO/LoadSettings.ps1
Feature engine
Registry tweaks and system mutation pipeline
- Execute changes · Central executor that turns selected options into OS changes
Scripts/Features/ExecuteChanges.ps1 - Registry bridge · Imports .reg payloads into the appropriate Windows context
Scripts/Features/ImportRegistryFile.ps1 - Regfiles · Curated registry tweaks, undo files, and sysprep variants
Regfiles - System actions · Restore points, Explorer restart, feature enablement, and related side effects
Scripts/Features/CreateSystemRestorePoint.ps1
App removal
App inventory and uninstall workflow
- App removal · Discovers installed apps and performs removals
Scripts/AppRemoval/RemoveApps.ps1 - Winget detect · Uses Winget metadata when available to find installed apps
Scripts/AppRemoval/GetInstalledAppsViaWinget.ps1 - Edge removal · Special removal path for Microsoft Edge
Scripts/AppRemoval/ForceRemoveEdge.ps1
Context helpers
User, profile, and environment resolution
- Context helpers · Resolves target user, profile paths, and runtime context
Scripts/Helpers/GetTargetUserForAppRemoval.ps1
Threading
Non-blocking execution helpers
- Non-blocking · Helpers that keep the GUI responsive during long operations
Scripts/Threading/Invoke-NonBlocking.ps1
Assets
Bundled images and startup artifacts
- UI assets · Images and startup artifacts used by the launcher and UI
Assets/Images
Connections 24
- Run.bat → Win11Debloat.ps1: launches · Batch launcher starts the PowerShell entry script
- Win11Debloat.ps1 → File I/O: loads/saves · Entry point reads default, saved, and imported settings
- Win11Debloat.ps1 → Context helpers: resolves context · Determines target user and execution context
- Win11Debloat.ps1 → Main window: opens GUI · Selects the GUI path when interactive mode is used
- Win11Debloat.ps1 → CLI menus: opens CLI · Selects the console path when non-GUI mode is used
- Main window → Config window: configures · Main GUI opens config/import-export views
- Main window → App picker: selects apps · Main GUI opens app selection UI
- Main window → Apply modal: applies · Shows progress modal while changes are executed
- Main window → Non-blocking: keeps responsive · GUI uses background/non-blocking helpers during long tasks
- CLI menus → App removal: drives · Console menus can trigger the app-removal workflow
- CLI menus → Execute changes: drives · Console menus can trigger feature application
- File I/O → Default settings: reads/writes · Settings persistence uses the default preset and saved state
- File I/O → Apps catalog: reads · Loads app definitions from JSON
- File I/O → Features map: reads · Loads feature mapping data from JSON
- File I/O → Context helpers: validates context · File I/O and config handling depend on user/profile resolution
- Execute changes → Registry bridge: imports tweaks · Executor applies selected registry-backed changes through the bridge
- Registry bridge → Regfiles: applies · Registry bridge selects standard, undo, or sysprep payloads
- Execute changes → System actions: runs side effects · Executor triggers restore points, Explorer restarts, and feature operations
- Execute changes → App removal: can invoke · Feature execution can hand off to app removal when selected
- App removal → Winget detect: discovers · Removal workflow probes installed apps via Winget when available
- App removal → Edge removal: special-cases · Dedicated path handles Edge removal separately
- App removal → Context helpers: targets user · App removal needs target-user and profile context
- Execute changes → Context helpers: targets user · Mutation engine resolves the correct user/profile boundary
- Win11Debloat.ps1 → UI assets: uses · Startup and UI presentation use bundled assets