# ionuttbara/windows-defender-remover architecture

> Architecture diagram of the GitHub repository ionuttbara/windows-defender-remover, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ionuttbara/windows-defender-remover
- Repository: https://github.com/ionuttbara/windows-defender-remover

## Overview

##### Project type and purpose
- This is a CLI‐driven, Windows system‐tweaking tool—a collection of scripts, registry modules, and an optional executable wrapper—designed to disable or remove Windows Defender and related security components on Windows 10+.
- There is no “frontend/backend” in the web sense; instead it comprises a command‐line entrypoint, a PowerShell/registry module engine, and many “.reg” files that are applied to the system.

##### File structure
- Top‐level entrypoints:
- Script_Run.bat (batch file that launches the process)
- PowerRun.exe / PowerRun.ini (elevation helper)
- Defender.Remover.exe (native wrapper for /r automation)
- Core scripts:
- RemoveSecHealthApp.ps1 (PowerShell to remove SecHealthUI)
- @Management/RegistryUnifier.ps1 (unifies and applies .reg files)
- Module folders (sets of .reg files):
- Remove_Defender
- Remove_SecurityComp
- Remove_SecurityComp_moduled
- Remove_defender_moduled
- Configuration & packaging:
- LICENSE, README.md, .github templates
- Script_Run.bat orchestrates the overall workflow

##### README for additional insights
- The README lists every component being disabled or removed (Windows Security Center services, VBS, SmartScreen, Telemetry, etc.).
- It describes two modes:
1. Interactive via the .exe or batch + PowerShell scripts
2. Automated via `Defender.Remover.exe /r` or passing parameters to the batch/PowerShell

A. User & Invocation Layer
- User double‐clicks Script_Run.bat or Defender.Remover.exe
- Optionally passes flags (`/r`) for unattended runs
B. Elevation Layer
- PowerRun.exe / PowerRun.ini ensures the process runs as Administrator
C. Orchestrator Layer
- Script_Run.bat (or native EXE)
- Calls PowerShell scripts (RemoveSecHealthApp.ps1, RegistryUnifier.ps1)
D. Module Engine
- RegistryUnifier.ps1 collects and applies all .reg files
- Removes Appx packages, executes DISM commands, bcdedit, etc.
E. Module Repositories
- Remove_Defender/*.reg
- Remove_SecurityComp/*.reg
- Remove_SecurityComp_moduled/*.reg
- Remove_defender_moduled/*.reg
F. External Dependencies (OS services & tools)
- Windows Registry
- DISM.exe (for Appx removal)
- PowerShell host
- bcdedit.exe
- Windows Security Services (wscsvc, SgrmBroker, etc.)

##### Relationships and data flow
1. User → Script_Run.bat (or .exe)
2. Script_Run.bat → PowerRun.exe (requests elevation)
3. Elevated process → Orchestrator (batch or EXE logic)
4. Orchestrator → PowerShell scripts (RemoveSecHealthApp.ps1, RegistryUnifier.ps1)
5. RegistryUnifier.ps1 → loads each .reg file and invokes DISM/cmdlets
6. OS services & registry are modified accordingly
7. Feedback/status → user console output

##### Architectural patterns & design principles
- Modular design: registry tweaks are separated into named folders.
- Orchestration script invokes modules in sequence.
- Single responsibility: each .reg file or .ps1 addresses one feature area.
- Layered elevation: batch → elevation helper → PowerShell → OS commands.

##### Details to capture
- Explicitly show the four module directories and that RegistryUnifier.ps1 iterates over them.
- Optional “Defender.Remover.exe” automated path.
- Use of PowerRun.exe for privilege elevation.
- Final effect targets: Windows Registry, Windows Services, Appx Packages, Boot Configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User & Invocation Layer
    subgraph "User & Invocation Layer"
        direction TB
        User("User"):::cli
        ScriptRun["Script_Run.bat<br/>(Batch Entrypoint)"]:::cli
        DefenderExe["Defender.Remover.exe<br/>(Automated EXE)"]:::cli
    end

    %% Elevation Layer
    subgraph "Elevation Layer"
        direction TB
        PowerRunExe["PowerRun.exe"]:::external
        PowerRunIni["PowerRun.ini"]:::external
    end

    %% Orchestrator Layer
    subgraph "Orchestrator Layer"
        direction TB
        Orchestrator["Script_Run.bat<br/>(Orchestrator Logic)"]:::orchestration
        NativeWrapper["Defender.Remover.exe<br/>(Native Wrapper)"]:::orchestration
    end

    %% Module Engine
    subgraph "Module Engine"
        direction TB
        RemoveSecHealth["RemoveSecHealthApp.ps1<br/>(Remove SecHealth UI)"]:::orchestration
        RegistryUnifier["RegistryUnifier.ps1<br/>(Module Loader)"]:::orchestration
    end

    %% Module Repositories
    subgraph "Module Repositories"
        direction TB
        DefDir["Remove_Defender/*.reg"]:::module
        SecCompDir["Remove_SecurityComp/*.reg"]:::module
        SecCompModDir["Remove_SecurityComp_moduled<br/>(Multiple .reg files)"]:::module
        DefModuledDir["Remove_defender_moduled<br/>(Multiple .reg files)"]:::module
    end

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        WindowsRegistry["Windows Registry"]:::external
        DISMExe["DISM.exe"]:::external
        PSHost["PowerShell Host"]:::external
        BcdeditExe["bcdedit.exe"]:::external
        WinServices["Windows Security Services"]:::external
    end

    %% Connections
    User -->|"invoke"| ScriptRun
    User -->|"invoke /r"| DefenderExe

    ScriptRun -->|"requests elevation"| PowerRunExe
    PowerRunExe -->|"reads settings"| PowerRunIni
    PowerRunExe -->|"launch elevated"| Orchestrator

    DefenderExe -->|"automated path"| NativeWrapper
    NativeWrapper -->|"calls PS scripts"| RemoveSecHealth

    Orchestrator -->|"calls PS script"| RemoveSecHealth
    Orchestrator -->|"calls PS script"| RegistryUnifier

    RemoveSecHealth -->|"runs on"| PSHost
    RemoveSecHealth -->|"modifies"| WinServices

    RegistryUnifier -->|"iterates .reg files"| DefDir
    RegistryUnifier -->|"iterates .reg files"| SecCompDir
    RegistryUnifier -->|"iterates .reg files"| SecCompModDir
    RegistryUnifier -->|"iterates .reg files"| DefModuledDir

    RegistryUnifier -->|"Import-Registry"| WindowsRegistry
    RegistryUnifier -->|"dism.exe /remove-appx"| DISMExe
    RegistryUnifier -->|"bcdedit /set hypervisorlaunchtype off"| BcdeditExe

    Orchestrator -->|"outputs status"| User

    %% Click Events
    click ScriptRun "https://github.com/ionuttbara/windows-defender-remover/blob/main/Script_Run.bat"
    click DefenderExe "https://github.com/ionuttbara/windows-defender-remover/blob/main/Defender.Remover.exe"
    click PowerRunExe "https://github.com/ionuttbara/windows-defender-remover/blob/main/PowerRun.exe"
    click PowerRunIni "https://github.com/ionuttbara/windows-defender-remover/blob/main/PowerRun.ini"
    click RemoveSecHealth "https://github.com/ionuttbara/windows-defender-remover/blob/main/RemoveSecHealthApp.ps1"
    click RegistryUnifier "https://github.com/ionuttbara/windows-defender-remover/blob/main/@Management/RegistryUnifier.ps1"
    click DefDir "https://github.com/ionuttbara/windows-defender-remover/blob/main/Remove_Defender/RemoveDefender.reg"
    click SecCompDir "https://github.com/ionuttbara/windows-defender-remover/blob/main/Remove_SecurityComp/Remove_SecurityComp.reg"
    click SecCompModDir "https://github.com/ionuttbara/windows-defender-remover/tree/main/Remove_SecurityComp_moduled"
    click DefModuledDir "https://github.com/ionuttbara/windows-defender-remover/tree/main/Remove_defender_moduled"

    %% Styles
    classDef cli fill:#cce5ff,stroke:#0056b3,color:#0056b3;
    classDef orchestration fill:#d4edda,stroke:#155724,color:#155724;
    classDef module fill:#fff3cd,stroke:#856404,color:#856404;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
