mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-10-09 06:56:41 +00:00
Compare commits
3
Commits
2026.08.24
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6012b02ea2 | ||
|
|
687ddea148 | ||
|
|
9b75b1a4e6 |
+74
-22
@@ -48,7 +48,7 @@ You can launch the prerelease version of Win11Debloat by running this command:
|
|||||||
2. Enable script execution if necessary:
|
2. Enable script execution if necessary:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Set-ExecutionPolicy Unrestricted -Scope Process -Force
|
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Navigate to your Win11Debloat directory
|
3. Navigate to your Win11Debloat directory
|
||||||
@@ -60,38 +60,74 @@ You can launch the prerelease version of Win11Debloat by running this command:
|
|||||||
|
|
||||||
### Running Automated Tests
|
### Running Automated Tests
|
||||||
|
|
||||||
The automated test cases use Pester 5 and do not modify the registry or other
|
The automated tests use Pester 5 and are found in the `Tests` directory. They cover registry operations, app removal, CLI/GUI logic, and config handling. Some Windows behavior is mocked so the tests can run safely, but they do not replace manual testing on a Windows test environment.
|
||||||
system state. The optional bootstrap step installs Pester for your user account
|
|
||||||
when needed. To run the complete suite:
|
The bootstrap option can be used to automatically install Pester on your machine and run the full suite of tests:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
.\Scripts\Run-Tests.ps1 -Bootstrap
|
.\Scripts\Run-Tests.ps1 -Bootstrap
|
||||||
```
|
```
|
||||||
|
|
||||||
After the initial setup, run the suite with:
|
After the initial setup, you can simply run the full suite with:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
.\Scripts\Run-Tests.ps1
|
.\Scripts\Run-Tests.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
GitHub Actions runs the same test command with Windows PowerShell 5.1 for pull
|
For a focused test run during development, you can also call Pester directly:
|
||||||
requests and pushes to `master`.
|
|
||||||
|
|
||||||
## Implementation Guidelines
|
```powershell
|
||||||
|
Invoke-Pester -Path .\Tests\Invoke-Changes.Tests.ps1 -Output Detailed
|
||||||
|
```
|
||||||
|
|
||||||
|
GitHub Actions runs the same suite with Windows
|
||||||
|
PowerShell 5.1 for pull requests and pushes to `master`.
|
||||||
|
|
||||||
|
## Architecture & Design
|
||||||
|
|
||||||
|
Win11Debloat is a PowerShell script with a WPF (Windows Presentation Foundation) based GUI and command-line interface. The CLI provides an alternative to the GUI, allowing most features to be invoked directly through command-line parameters. The project uses a data-driven architecture, separating feature and application definitions from the logic that applies them.
|
||||||
|
|
||||||
|
### Entry Points
|
||||||
|
|
||||||
|
`Win11Debloat.ps1` is the main entry point and can be launched directly or through one of the provided launchers:
|
||||||
|
|
||||||
|
* `Run.bat` launches a locally downloaded copy of `Win11Debloat.ps1`.
|
||||||
|
* `Get.ps1` downloads Win11Debloat and launches `Win11Debloat.ps1`.
|
||||||
|
|
||||||
|
Both `Get.ps1` and `Win11Debloat.ps1` support [command-line parameters](https://github.com/Raphire/Win11Debloat/wiki/Command-Line-Interface), allowing Win11Debloat to be configured and run without using the GUI.
|
||||||
|
|
||||||
|
### High-Level Architecture
|
||||||
|
|
||||||
|
`Win11Debloat.ps1` loads the configuration and shared functions, then routes execution through either the WPF GUI or CLI. Both interfaces use the same underlying feature and app-removal engine.
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TB
|
||||||
|
Main[Win11Debloat.ps1] --> GUI[WPF GUI]
|
||||||
|
Main --> CLI[CLI]
|
||||||
|
|
||||||
|
Config["Config Files (JSON)"] --> GUI
|
||||||
|
Config --> CLI
|
||||||
|
|
||||||
|
GUI --> Changes[Apply Selected Changes]
|
||||||
|
CLI --> Changes
|
||||||
|
Config --> Changes
|
||||||
|
|
||||||
|
Changes --> Regfiles[Regfiles]
|
||||||
|
Changes --> Tools[Appx / WinGet]
|
||||||
|
```
|
||||||
|
|
||||||
### Project Structure
|
### Project Structure
|
||||||
|
|
||||||
Understanding the project structure is essential for contributing effectively:
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Win11Debloat/
|
Win11Debloat/
|
||||||
├── Win11Debloat.ps1 # Main PowerShell script
|
├── Win11Debloat.ps1 # Main PowerShell script
|
||||||
├── Run.bat # Batch launcher for the quick launch method
|
├── Run.bat # Local launcher
|
||||||
├── Scripts/ # Additional PowerShell scripts and functions
|
├── Scripts/ # Additional PowerShell scripts and functions
|
||||||
│ ├── Get.ps1 # Script used for the quick launch method to automatically download and run Win11debloat
|
│ ├── Get.ps1 # Download-and-launch script
|
||||||
|
│ ├── Run-Tests.ps1 # Pester test runner (optionally bootstraps Pester)
|
||||||
│ ├── AppRemoval/ # App package removal logic
|
│ ├── AppRemoval/ # App package removal logic
|
||||||
│ ├── CLI/ # Command-line interface helpers
|
│ ├── CLI/ # Command-line interface helpers
|
||||||
│ ├── Features/ # Feature apply/undo logic (e.g. Invoke-Changes.ps1, Replace-StartMenu.ps1)
|
│ ├── Features/ # Feature apply, undo, backup, and restore logic
|
||||||
│ ├── FileIO/ # File input/output helpers
|
│ ├── FileIO/ # File input/output helpers
|
||||||
│ ├── GUI/ # GUI window definitions and logic
|
│ ├── GUI/ # GUI window definitions and logic
|
||||||
│ ├── Helpers/ # Shared helper functions
|
│ ├── Helpers/ # Shared helper functions
|
||||||
@@ -104,16 +140,19 @@ Win11Debloat/
|
|||||||
├── Regfiles/ # Registry files for all features
|
├── Regfiles/ # Registry files for all features
|
||||||
│ ├── Undo/ # Registry files for reverting features
|
│ ├── Undo/ # Registry files for reverting features
|
||||||
│ └── Sysprep/ # Registry files for Sysprep mode
|
│ └── Sysprep/ # Registry files for Sysprep mode
|
||||||
├── Schemas/ # XAML Schemas for GUI elements
|
├── Schemas/ # XAML views and shared GUI resources
|
||||||
├── Assets/ # Static assets (icons, start menu templates)
|
├── Assets/ # Static assets (icons, start menu templates)
|
||||||
|
├── Tests/ # Pester tests for script and XAML contracts
|
||||||
├── Backups/ # Registry backups (generated during use)
|
├── Backups/ # Registry backups (generated during use)
|
||||||
└── Logs/ # Script logs (generated during use)
|
└── Logs/ # Script logs (generated during use)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Implementation Guidelines
|
||||||
|
|
||||||
### Best Practices
|
### Best Practices
|
||||||
|
|
||||||
1. **Test Thoroughly**: Always test your changes on a Windows test environment before submitting. This includes undoing tweaks and running script as another user and in Sysprep mode.
|
1. **Test Thoroughly**: Always test your changes on a Windows test environment before submitting. This includes undoing tweaks and running script as another user and in Sysprep mode.
|
||||||
2. **Document Changes**: Update the `README.md` and other relevant documentation. Wiki documentation will be generated/updated based on the `Features.json` and `Apps.json` files.
|
2. **Document Changes**: Update the `README.md`, wiki, and other relevant documentation.
|
||||||
3. **Follow Existing Patterns**: Look at existing implementations for guidance.
|
3. **Follow Existing Patterns**: Look at existing implementations for guidance.
|
||||||
4. **Use Clear Naming**: Choose descriptive names for features, IDs, and registry files.
|
4. **Use Clear Naming**: Choose descriptive names for features, IDs, and registry files.
|
||||||
5. **Minimal Changes**: Registry files should only modify what's necessary. Avoid using policies where possible.
|
5. **Minimal Changes**: Registry files should only modify what's necessary. Avoid using policies where possible.
|
||||||
@@ -137,7 +176,7 @@ Avoid these common mistakes when contributing:
|
|||||||
|
|
||||||
1. **Forgetting Get.ps1**: When adding a new command-line parameter, contributors often remember to add it to `Win11Debloat.ps1` but forget to add the same parameter to `Scripts/Get.ps1`. Both files **must** have matching parameters.
|
1. **Forgetting Get.ps1**: When adding a new command-line parameter, contributors often remember to add it to `Win11Debloat.ps1` but forget to add the same parameter to `Scripts/Get.ps1`. Both files **must** have matching parameters.
|
||||||
|
|
||||||
2. **Missing Registry Files**: Always create an `Undo` registry file for reversibility, aswell as a `Sysprep` registry file for applying changes to other users and Sysprep mode.
|
2. **Missing Registry Files**: For registry-backed features, create an `Undo` registry file for reversibility and a `Sysprep` registry file for applying changes to other users and Sysprep mode.
|
||||||
|
|
||||||
3. **Incorrect Registry Hives for Sysprep**: Sysprep registry files are meant to apply changes to a different user. Registry keys in the `HKEY_CURRENT_USER` hive must use `hkey_users\default` instead. Ensure you update **all** registry keys in the file.
|
3. **Incorrect Registry Hives for Sysprep**: Sysprep registry files are meant to apply changes to a different user. Registry keys in the `HKEY_CURRENT_USER` hive must use `hkey_users\default` instead. Ensure you update **all** registry keys in the file.
|
||||||
|
|
||||||
@@ -165,12 +204,14 @@ Avoid these common mistakes when contributing:
|
|||||||
|
|
||||||
To add a new app that can be removed via Win11Debloat:
|
To add a new app that can be removed via Win11Debloat:
|
||||||
|
|
||||||
1. **Find the AppId**: To find the correct AppId for an app:
|
1. **Find the AppId**: For an Appx app, find the package name with:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
Get-AppxPackage | Select-Object Name, PackageFullName
|
Get-AppxPackage | Select-Object Name, PackageFullName
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For a WinGet app, use `winget list` and use its `Id` value.
|
||||||
|
|
||||||
2. **Edit `Config/Apps.json`**: Add a new entry to the `"Apps"` array:
|
2. **Edit `Config/Apps.json`**: Add a new entry to the `"Apps"` array:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@@ -187,7 +228,9 @@ To add a new app that can be removed via Win11Debloat:
|
|||||||
**Field Descriptions**:
|
**Field Descriptions**:
|
||||||
|
|
||||||
- `FriendlyName`: Display name shown in the GUI.
|
- `FriendlyName`: Display name shown in the GUI.
|
||||||
- `AppId`: The `AppPackageIdentifier` from `Get-AppxPackage` or the `Id` from `winget list`, depending on removal method.
|
- `AppId`: The package name from `Get-AppxPackage` or the `Id` from
|
||||||
|
`winget list`, depending on removal method. Use an array when one app
|
||||||
|
requires multiple identifiers.
|
||||||
- `Description`: Brief description of the app shown in the GUI.
|
- `Description`: Brief description of the app shown in the GUI.
|
||||||
- `SelectedByDefault`: Set to `true` only for apps that are largely considered bloatware, otherwise set to `false`.
|
- `SelectedByDefault`: Set to `true` only for apps that are largely considered bloatware, otherwise set to `false`.
|
||||||
- `Recommendation`: Indicates how strongly the app is recommended for removal. One of:
|
- `Recommendation`: Indicates how strongly the app is recommended for removal. One of:
|
||||||
@@ -201,7 +244,6 @@ To add a new app that can be removed via Win11Debloat:
|
|||||||
3. **Follow the Guidelines**:
|
3. **Follow the Guidelines**:
|
||||||
|
|
||||||
- Use clear, user-friendly names for `FriendlyName`
|
- Use clear, user-friendly names for `FriendlyName`
|
||||||
- Set `SelectedByDefault` to `true` only for apps that are largely considered bloatware, otherwise set to `false`
|
|
||||||
- Provide a concise description explaining what the app does
|
- Provide a concise description explaining what the app does
|
||||||
|
|
||||||
### Adding a New Feature
|
### Adding a New Feature
|
||||||
@@ -289,6 +331,10 @@ Add a corresponding parameter to both `Win11Debloat.ps1` AND `Scripts/Get.ps1`,
|
|||||||
[switch]$YourFeatureId,
|
[switch]$YourFeatureId,
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### 4. Add or Update Tests
|
||||||
|
|
||||||
|
Add or update Pester coverage for the new behavior, then run the full suite.
|
||||||
|
|
||||||
### Adding a Feature to the Default Preset
|
### Adding a Feature to the Default Preset
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
@@ -354,8 +400,9 @@ To add a new category for organizing features:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"CategoryId": "YourCategoryId",
|
||||||
"Name": "Your Category Name",
|
"Name": "Your Category Name",
|
||||||
"Icon": "#### ;"
|
"Icon": "####;"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -364,7 +411,9 @@ To add a new category for organizing features:
|
|||||||
|
|
||||||
### Adding UI Groups
|
### Adding UI Groups
|
||||||
|
|
||||||
UI Groups allow features to be grouped together in the GUI with a combobox (dropdown) selection:
|
UI Groups allow features to be grouped together in the GUI with a combobox
|
||||||
|
(dropdown) selection. Add the group to the top-level `"UiGroups"` array in
|
||||||
|
`Config/Features.json` and use a unique `GroupId`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -386,6 +435,9 @@ UI Groups allow features to be grouped together in the GUI with a combobox (drop
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
>[!IMPORTANT]
|
||||||
|
> Define the referenced features before adding a group. Each `FeatureId` in a group's `Values` list must already be defined in the `"Features"` array in `Features.json`. Features referenced by a group are shown through that group rather than as standalone controls.
|
||||||
|
|
||||||
## Submitting a Pull Request
|
## Submitting a Pull Request
|
||||||
|
|
||||||
1. **Commit your changes** with clear, descriptive commit messages:
|
1. **Commit your changes** with clear, descriptive commit messages:
|
||||||
@@ -406,7 +458,7 @@ UI Groups allow features to be grouped together in the GUI with a combobox (drop
|
|||||||
- Go to the original Win11Debloat repository
|
- Go to the original Win11Debloat repository
|
||||||
- Click "New Pull Request"
|
- Click "New Pull Request"
|
||||||
- Select your fork and branch
|
- Select your fork and branch
|
||||||
- Provide a clear description of your changes, include references to the registry keys used
|
- Provide a clear description of your changes. For registry changes, include the registry keys used
|
||||||
- Reference any related issues
|
- Reference any related issues
|
||||||
|
|
||||||
4. **Respond to feedback**: Be prepared to make adjustments based on code review feedback.
|
4. **Respond to feedback**: Be prepared to make adjustments based on code review feedback.
|
||||||
|
|||||||
Reference in New Issue
Block a user