# Windows Performance Tweaker 10/11

A Visual Basic .NET (WinForms) utility for optimizing Windows 10 and Windows 11 performance, network throughput, and disk hygiene. Licensed under **BSD 3-Clause**.

---

## Table of Contents

- [Features](#features)
- [Screenshots](#screenshots)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
  - [Visual Performance](#1-visual-performance-tab)
  - [TCP / UDP Optimization](#2-tcp--udp-optimization-tab)
  - [Disk Cleanup](#3-disk-cleanup-tab)
  - [Memory Management](#4-memory-management-tab)
  - [Output Log](#5-output-log-tab)
  - [Tools](#6-tools-tab)
  - [Backup & Restore](#7-backup--restore-tab)
- [Registry Keys Modified](#registry-keys-modified)
- [Backup System](#backup-system)
- [Update System](#update-system)
- [Development](#development)
  - [Prerequisites](#prerequisites)
  - [Building from Source](#building-from-source)
  - [Project Structure](#project-structure)
  - [Extending the Application](#extending-the-application)
- [How It Works](#how-it-works)
  - [Platform Detection](#platform-detection)
  - [Self-Elevation](#self-elevation)
  - [Status Checking](#status-checking)
- [Language System](#language-system)
- [Security Considerations](#security-considerations)
- [License](#license)
- [Author](#author)
- [Resources](#resources)

---

## Features

### Visual Performance Tweaks
- Disable transparency effects, animations, window shadows, menu animations, taskbar animations, window animations, list-box animations, tooltip animations, and combo-box animations.
- "Adjust for best performance" mode — sets `VisualFXSetting = 2` and writes all performance-oriented registry values in a single click using `UserPreferencesMask`.
- Changes are applied per-user (`HKCU`) and take effect after logoff/restart.

### TCP / UDP Network Optimization
- **TCP Auto-Tuning** — ensures `autotuninglevel=normal` via `netsh`.
- **Disable Nagle's Algorithm** — sets `TCPNoDelay = 1` and `TcpAckFrequency = 1` on every network interface.
- **QoS DSCP Tagging** — sets DSCP value to 46 (Expedited Forwarding) for reduced latency.
- **Increased Ephemeral Port Range** — `MaxUserPort = 65534`, `TcpTimedWaitDelay = 30`, `TcpNumConnections = 16777214`.
- **Receive Side Scaling (RSS)** — enables RSS for multi-core network load distribution.
- **TCP ACK Frequency** — reduces ACK overhead with `TCPDelAckTicks = 0`.
- **System Responsiveness** — sets `SystemResponsiveness = 10` for foreground application network priority.
- Administrative privileges required for all network tweaks.

### Disk Cleanup
- **Temporary Files** — user temp, Windows temp, and `cleanmgr /sagerun:1`.
- **Temporary Internet Files** — Internet Explorer cache and Edge (Chromium) cache, code cache, media cache.
- **SoftwareDistribution** — stops Windows Update / BITS / DoSvc services, cleans `SoftwareDistribution\Download`, restarts services.
- **Prefetch** — removes `*.pf` files.
- **Recycle Bin** — empties via `rd /s C:\$Recycle.bin` and PowerShell `Clear-RecycleBin`.
- **Windows Error Reporting** — user and system WER archives, clears System and Application event logs.
- **Delivery Optimization** — cleans `SoftwareDistribution\DeliveryOptimization` and runs `DISM /StartComponentCleanup /ResetBase`.
- **DISM / WinSxS** — runs `StartComponentCleanup /ResetBase`, `SPSuperseded`, and deletes Volume Shadow Copies.
- **Browser Caches** — Chrome, Edge, Firefox, and Brave cache directories.

### Backup & Restore
- Full registry snapshots of all 23 known registry keys before modification.
- Session-level incremental backups when applying tweaks.
- Restore any specific backup from a dated list.
- Export backups as `.reg` files compatible with regedit.
- All backups stored in `%LOCALAPPDATA%\WindowsTweaker\Backups\`.

### Status Checking
- On launch, automatically scans every registry value and synchronizes checkbox states — no tab switch occurs, the app stays on the Visual Performance tab.
- Individual checkbox states are synchronized to match the actual system state.
- `netsh interface tcp show global` output is parsed for network-related global parameters.
- Use **/visual**, **/network**, **/cleanup**, **/tools**, **/backup**, or **/output** command line switches to start on a different tab.

### Self-Elevation
- Detects if not running as Administrator and offers to restart with elevated privileges.

### Update Checking
- Fetches latest version from a configurable URL (default: GitHub raw).
- Prompts to open the download page if a newer version is available.

### Language / Translation System
- All user-facing strings are loaded from external JSON files in `Lang\`.
- The app auto-detects the system UI language on startup — no code changes needed.
- **Manual override:** Use the language ComboBox on the Tools tab to switch languages at runtime. The selection is saved to `%LOCALAPPDATA%\WindowsTweaker\settings.json` and persists across restarts.
- Apply a new language by dropping a `{code}.json` file into the `Lang\` folder.
- Language detection: saved preference → full culture name → two-letter code → `en` fallback.
- Included languages: **English**, **German**, **French**, **Spanish**, **Portuguese**, **Japanese**, **Chinese Simplified**.

---

## Requirements

| Requirement | Details |
|-------------|---------|
| **Operating System** | Windows 10 (build 10240+) or Windows 11 (build 22000+) |
| **.NET Runtime** | .NET 10.0 (or later) Desktop Runtime (included with Windows App SDK) |
| **Privileges** | Administrator rights recommended for full functionality |
| **Disk Space** | ~5 MB for the application |

---

## Installation

1. **Download the latest release** from the [Releases](https://github.com/yourusername/WindowsTweaker/releases) page.
2. Extract the archive to a folder of your choice.
3. Run `WindowsTweaker.exe` — **right-click and select "Run as administrator"** for full functionality.

Alternatively, build from source (see [Development](#development)).

### Command Line Switches

Start directly on a specific tab:

| Switch | Target Tab |
|--------|------------|
| `/visual` or `--visual` | Visual Performance (default) |
| `/network` or `--network` | TCP / UDP Optimization |
| `/cleanup` or `--cleanup` | Disk Cleanup |
| `/memory` or `--memory` | Memory Management |
| `/tools` or `--tools` | Tools |
| `/backup` or `--backup` | Backup & Restore |
| `/output` or `--output` | Output Log |

The generic form `/tab:<name>` or `--tab:<name>` also works, accepting longer names like `performance`, `tcp`, `disk`, `memory`, `restore`, and `log`.

```powershell
WindowsTweaker.exe --network
WindowsTweaker.exe /tab:Cleanup
```

---

## Usage

### 1. Visual Performance Tab

Check the boxes for visual effects you want to disable, then click **Apply Visual Tweaks**.

| Checkbox | Registry Key | Value |
|----------|--------------|-------|
| Adjust for best performance | `VisualFXSetting` | `2` |
| Disable Transparency Effects | `EnableTransparency` | `0` |
| Disable Animations / Window Animations | `MinAnimate` | `0` |
| Disable Window Shadow Effects | `DisablePreviewDesktop` | `1` |
| Disable Menu Animations | `MenuShowDelay` | `"0"` |
| Disable Taskbar Animations | `TaskbarAnimations` | `0` |
| Disable List Box Animations | `ListviewAlphaSelect` | `0` |
| Disable Tooltip Animations | `EnableBalloonTips` | `0` |
| Disable Combo Box Animations | `SmoothScroll` | `0` |

The **Select All** button toggles all checkboxes on/off.

### 2. TCP / UDP Optimization Tab

Check the optimizations you want to apply, then click **Apply Network Tweaks**.

| Checkbox | What It Does |
|----------|--------------|
| Enable TCP Auto-Tuning | Sets `autotuninglevel=normal` via `netsh` |
| Disable Nagle's Algorithm | Sets `TCPNoDelay=1` and `TcpAckFrequency=1` per interface |
| Enable QoS DSCP Tagging | Sets DSCP value `46` (Expedited Forwarding) |
| Increase ephemeral port range | Expands dynamic port range for more concurrent connections |
| Enable RSS | Receive Side Scaling for multi-core CPUs |
| Enable TCP ACK Frequency | Reduces ACK delay overhead |
| Set SystemResponsiveness | Sets foreground app network priority to `10` |

### 3. Disk Cleanup Tab

Select the cleanup targets (most are checked by default), then click **Run Cleanup**.

Some operations (SoftwareDistribution, DISM) require services to be stopped/started and may take several minutes.

### 4. Memory Management Tab

Displays real-time system memory information and provides tools to reclaim RAM.

**Memory Overview** (left panel)
- **Total** — total installed physical RAM.
- **Free** — currently available physical RAM.
- **In Use** — amount and percentage of RAM in use (visual progress bar below).
- **Committed** — total committed memory (page file + physical).

**Top Processes** (right panel)
- Lists the top 30 processes by working set size, showing process name, PID, and memory usage in MB.

**Actions**
| Button | Function |
|--------|----------|
| Refresh | Updates memory stats and process list. |
| Free Up Memory | Calls `EmptyWorkingSet()` on all non-system processes to trim working sets. |
| Clear Standby Cache | Runs a garbage collection and releases standby memory (requires admin). |
| Release Idle Tasks | Triggers `ProcessIdleTasks` via `rundll32` to release resources from idle background tasks. |

### 5. Output Log Tab

Real-time console-style log with color-coded messages:
- **Green** — informational messages.
- **Cyan** — success / applied.
- **Yellow** — warnings.
- **Red** — errors.

The log is read-only and word-wrap is disabled for easy reading.

### 6. Tools Tab

Controls are organized into three group boxes:

**System**
- **Check Current Status** — Runs the same status scan as on startup. Logs results and updates checkbox states.

**Language**
- **Language selector** — A ComboBox that lists all available languages. Selecting a different language instantly re-applies all UI text and saves the preference for next launch.

**Application**
- **Check for Updates** — Fetches the latest version from the configured URL and compares against the current version.
- **About** — Opens the About dialog displaying version info, copyright, and share buttons (Twitter/X, Facebook, Email, copy link).

### 7. Backup & Restore Tab

| Button | Function |
|--------|----------|
| Create Backup Now | Takes a full snapshot of all 23 tracked registry keys. |
| Restore Selected | Restores registry values from the selected backup file. |
| Delete Selected | Removes the selected backup file from disk. |
| Export as .reg File | Converts the selected backup into a standard `.reg` file that can be double-clicked to merge into the registry. |

The list shows all available backups sorted newest-first, with creation date, entry count, and file size.

---

## Registry Keys Modified

### HKEY_CURRENT_USER (Visual Performance)

```
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects
    VisualFXSetting = 2

HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
    EnableTransparency = 0

HKCU\Control Panel\Desktop\WindowMetrics
    MinAnimate = 0

HKCU\Control Panel\Desktop
    MenuShowDelay = "0"
    SmoothScroll = 0
    UserPreferencesMask = binary mask

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
    TaskbarAnimations = 0
    DisablePreviewDesktop = 1
    ListviewShadow = 0
    ListviewAlphaSelect = 0
    EnableBalloonTips = 0
    DisallowShaking = 1
    EnableSnapAssist = 0
    EnableSnapFlyout = 0
```

### HKEY_LOCAL_MACHINE (Network / TCP-UDP)

```
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
    MaxUserPort = 65534
    TcpTimedWaitDelay = 30
    TcpNumConnections = 16777214
    EnableRSS = 1
    MaxNumRssCpus = 4
    TCPDelAckTicks = 0

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{GUID}
    TCPNoDelay = 1
    TcpAckFrequency = 1

HKLM\SYSTEM\CurrentControlSet\Services\Psched\Parameters
    SystemResponsiveness = 10

HKLM\SOFTWARE\Policies\Microsoft\Windows\QoS
    DSCP Value = 46

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\QoS
    Do not use NLA = 1
```

---

## Backup System

All backups are stored in:

```
%LOCALAPPDATA%\WindowsTweaker\Backups\backup_YYYYMMDD_HHmmss.json
```

### Backup Format

Each backup file is a JSON array. The first element contains metadata (`__meta__`), followed by entries for each registry value:

```json
[
  {
    "__meta__": {
      "version": "2.0",
      "created": "2026-06-18 14:30:00",
      "appVersion": "1.0.0"
    }
  },
  {
    "KeyPath": "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
    "ValueName": "EnableTransparency",
    "ValueKind": 4,
    "ValueData": "0",
    "IsBinary": false,
    "IsMultiString": false
  }
]
```

- **KeyPath** — Full registry path prefixed with `HKLM\` or `HKCU\`.
- **ValueName** — The registry value name.
- **ValueKind** — Integer representing `RegistryValueKind` (4 = DWord, 1 = String, etc.).
- **ValueData** — String representation of the value. Binary data is Base64-encoded.
- **IsBinary** — `true` if the original value was a binary (`REG_BINARY`) type.
- **IsMultiString** — `true` if the original value was a multi-string (`REG_MULTI_SZ`) type.

### .reg Export

The "Export as .reg" feature converts a backup into a standard Windows registry file:

```registry
Windows Registry Editor Version 5.00

[HKCU\Control Panel\Desktop]
"MenuShowDelay"="0"
"SmoothScroll"=dword:00000000
```

Supported value encodings:
- `dword:XXXXXXXX` — REG_DWORD
- `hex(b):XX,XX,...` — REG_QWORD
- `hex:XX,XX,...` — REG_BINARY
- `"value"="data"` — REG_SZ
- `hex(2):XX,XX,...` — REG_EXPAND_SZ
- `hex(7):XX,XX,...` — REG_MULTI_SZ

### Session Backups

When applying visual or network tweaks, the tool creates an additional backup capturing only the values modified during that session (including per-interface Nagle settings). These are stored alongside full snapshots.

---

## Update System

The application checks for updates against a configurable URL:

```vb
Private Const UPDATE_URL As String = "https://raw.githubusercontent.com/yourusername/WindowsTweaker/main/version.txt"
Private Const DOWNLOAD_URL As String = "https://github.com/yourusername/WindowsTweaker/releases/latest"
```

To set up your own update channel:

1. Create a `version.txt` file containing a single line with the latest version number (e.g., `1.0.1`).
2. Host it at the URL specified in `UPDATE_URL`.
3. Point `DOWNLOAD_URL` to your releases page.
4. Each time a user clicks "Check for Updates", the app fetches `version.txt`, compares it to the embedded `APP_VERSION`, and prompts to open the download page if a newer version exists.

---

## Development

### Prerequisites

- [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) (or later)
- Windows 10/11 (the application targets `net10.0-windows`)
- Visual Studio 2022+ or any editor with VB.NET support (VS Code with Ionide-fsharp extension works)

### Building from Source

```powershell
# Clone the repository
git clone https://github.com/yourusername/WindowsTweaker.git
cd WindowsTweaker

# Restore dependencies and build
dotnet restore
dotnet build

# Build a release version
dotnet build -c Release

# Publish as a self-contained single-file executable
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
```

The built executable will be at:
- Debug: `bin\Debug\net10.0-windows\WindowsTweaker.exe`
- Release: `bin\Release\net10.0-windows\WindowsTweaker.exe`

### Project Structure

```
WindowsTweaker/
├── Program.vb              # Entry point — STAThread Main
├── Form1.vb                # Main form — all tweak logic, backup, restore, update, status
├── Form1.Designer.vb       # UI layout — all controls and their properties
├── AboutDialog.vb          # About dialog — version, copyright, share buttons
├── AboutDialog.Designer.vb # About dialog layout
├── LanguageManager.vb      # Module — loads/applies translations, Tr() helper
├── WindowsTweaker.vbproj   # MSBuild project file
├── WindowsTweaker.sln      # Solution file
├── Lang/
│   ├── en.json             # English (default)
│   ├── de.json             # Deutsch / German
│   ├── es.json             # Español / Spanish
│   ├── fr.json             # Français / French
│   ├── ja.json             # 日本語 / Japanese
│   ├── pt.json             # Portuguese / Portuguese
│   └── zh.json             # 简体中文 / Chinese (Simplified)
├── README.md               # This file
└── bin/                    # Build output
```

### Extending the Application

#### Adding a New Visual Tweak

1. Add a new `CheckBox` control in `Form1.Designer.vb`.
2. In `Form1.vb`, add an `ApplyVisual*()` method that calls `BackupRegistryValue()` then `SetRegistryKey()`.
3. Wire the checkbox into `BtnVisualApply_Click` with an `If` check.
4. Add the corresponding registry path to `KnownRegistryKeys` and to `SyncCheckboxesToStatus()`.
5. Add a `ReportReg()` call in `CheckVisualStatus()`.

#### Adding a New Network Tweak

1. Add a new `CheckBox` in `Form1.Designer.vb`.
2. Add an `ApplyNetwork*()` method that uses `RunAdmin()` and/or `SetRegistryKey()`.
3. Wire into `BtnNetworkApply_Click`.
4. Add the registry path to `KnownRegistryKeys` and `SyncCheckboxesToStatus()`.
5. Add a `ReportReg()` call in `CheckNetworkStatus()`.

#### Adding a New Cleanup Target

1. Add a new `CheckBox` in `Form1.Designer.vb`.
2. Create a `Cleanup*()` method using `DeleteDirContents()` and/or `RunAdmin()`.
3. Wire into `BtnCleanupRun_Click`.

#### Adding a New Language

1. Copy `Lang\en.json` to `Lang\{code}.json` (e.g., `Lang\it.json` for Italian).
2. Update the `meta.code` field to match the file name.
3. Translate every string value (keep all keys intact, do not change the structure).
4. Rebuild — the app will auto-detect the system locale on next launch.

Language resolution order:
```
saved preference → CurrentCulture.Name (e.g. "zh-Hans") → TwoLetterISOLanguageName ("zh") → "en"
```

#### Changing the Update URLs

Edit the constants at the top of `Form1.vb`:

```vb
Private Const UPDATE_URL As String = "https://your-domain.com/version.txt"
Private Const DOWNLOAD_URL As String = "https://your-domain.com/downloads"
```

---

## How It Works

### Platform Detection

On startup, `IsWindows10Or11()` checks:
1. `Environment.OSVersion.Version` — if `Major = 10` and `Build >= 10240`, it passes.
2. Falls back to `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuild` for compatibility.

Windows 11 reports build `22000+` but shares the same major version `10` as Windows 10.

### Self-Elevation

The `IsRunningAsAdmin()` function checks if the current process token contains the Administrators group. If not, `RestartAsAdmin()` re-launches the `.exe` with `ProcessStartInfo.Verb = "runas"`, which triggers the Windows UAC prompt.

### Status Checking

`SyncCheckboxesToStatus()` reads current registry values using:
- `ReadDWord()` — reads `REG_DWORD` values, returns `-1` on failure.
- `ReadRegString()` — reads `REG_SZ` values.
- `CheckNagleAllInterfaces()` — iterates all network interfaces checking for `TCPNoDelay = 1`.
- `CheckTcpAutoTuning()` — runs `netsh interface tcp show global` and parses the output.

### Language System

`LanguageManager.vb` is a module that manages all translation data:

```vb
' Core API
LoadLanguage(code?)        ' Reads Lang\{code}.json. If omitted: saved preference →
                           ' CurrentUICulture.Name → two-letter code → "en".
Tr(key, args...)           ' Looks up key, applies String.Format, or returns fallback.
ApplyUIText(form)          ' Walks all controls, tabs, columns, status items, sets .Text.

' Persistence
GetAvailableLanguages()    ' Returns List(Of (Code, DisplayName)) from Lang\*.json meta.
SaveLanguagePreference(code)  ' Writes to %LOCALAPPDATA%\WindowsTweaker\settings.json.
LoadLanguagePreference()      ' Reads saved preference from settings.json.
```

Keys use a dot‑notation namespace: `app.*` (window title), `ui.*` (control text), `msg.*` (log messages and dialogs).

All user-facing strings in `Form1.vb` call `Tr("msg.key", ...)` or `Tr("ui.Key")` — there are zero hardcoded display strings in the codebase.

### Registry Access

- **`SetRegistryKey()`** — opens or creates a subkey, sets a value, and disposes.
- **`BackupRegistryValue()`** — reads the current value before modification and stores it in the session backup list.
- **`ReportReg()`** — reads and compares a value against an expected state, logging the result.

---

## Security Considerations

- **Administrator privileges** are required for network tweaks, most cleanup operations, and registry writes under `HKLM`. The application will prompt for elevation on startup.
- **Registry changes** affect system-wide behavior. Use the backup and restore system to revert changes.
- **File cleanup** operations permanently delete files. Ensure important data is not stored in temporary directories before running cleanup.
- **The application does not phone home** except for the optional update check, which fetches a single version string from a user-configurable URL.
- **All backups are stored locally** in `%LOCALAPPDATA%\WindowsTweaker\Backups\` and are never transmitted.

---

## License

```
Copyright © 1992-2026 Charles McDonald

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
```

---

## Author

**Charles McDonald**

- GitHub: [@BoredOutkast](https://github.com/BoredOutkast)

*Windows Performance Tweaker 10/11* was created to provide a single, unified tool for optimizing Windows visual performance, network throughput (TCP/UDP), and disk hygiene — with full backup and restore capabilities.

---

## Resources

- [.NET Documentation](https://learn.microsoft.com/dotnet/)
- [Windows Registry Information](https://learn.microsoft.com/windows/win32/sysinfo/registry)
- [TCP/IP Registry Parameters](https://learn.microsoft.com/windows/win32/networking/tcpip-registry-parameters)
- [Nagle's Algorithm](https://learn.microsoft.com/troubleshoot/windows-server/networking/overview-tcp-performance-nagle-algorithm)
- [QoS / DSCP](https://learn.microsoft.com/windows/win32/qos/qos-start-page)
- [DISM Command-Line Options](https://learn.microsoft.com/windows-hardware/manufacture/desktop/dism-image-management-command-line-options)
- [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)

---

*Built with .NET 10 and Visual Basic .NET — Windows Forms.*
