---
name: windows-gaming-optimization
title: Windows Gaming Optimization (Remote from Linux)
description: Remotely audit, debloat, and optimize a Windows gaming PC from a Linux host. Covers SSH/powershell remote execution, system inventory, service disabling, GPU/network/game-mode registry tweaks, and cleanup — all via SSH + PowerShell.
triggers:
  - User asks to audit, debloat, or optimize a Windows gaming machine
  - User provides Windows IP and credentials for remote management
  - Need to interact with Windows services/registry/power remotely from Linux
---

## Tools

- `sshpass` (for password-based SSH)
- `ssh` + `scp`  
- PowerShell on the target (Windows 10/11 with OpenSSH Server)

## Workflow

### 1. Pre-flight Checks

```bash
# Quick reachability
ping -c2 $WIN_IP
# Quick SSH test
sshpass -p 'PASSWORD' ssh -o ConnectTimeout=10 $USER@$IP "hostname && whoami"
```

If host key changed (dual-boot machine), clear old key:
```bash
ssh-keygen -f ~/.ssh/known_hosts -R $IP
```

### 2. System Audit

Write a comprehensive PowerShell audit script locally, SCP to Windows, execute:

```bash
# Copy to Windows
sshpass -p 'PASSWORD' scp /tmp/audit.ps1 $USER@$IP:C:/Users/$USER/audit.ps1
# Run
sshpass -p 'PASSWORD' ssh $USER@$IP "powershell -ExecutionPolicy Bypass -File C:/Users/$USER/audit.ps1"
```

Key audit info to collect:
- OS version, build, edition, architecture
- CPU (model, cores, threads, clock)
- RAM (capacity per stick, speed, manufacturer)
- GPU (model, VRAM, driver, resolution, refresh rate)
- Storage (drive letter, size, free space, free %)
- Motherboard (manufacturer, model, BIOS)
- Network (description, IP, MAC, gateway)
- Top CPU and memory processes
- Running services
- Startup programs
- Installed software

### 3. Optimizations — Phase 1 (Safe & Reversible)

Apply immediately — these are non-destructive:

| Category | Action | Impact |
|---|---|---|
| **Power** | Ultimate Performance plan, USB suspend OFF, CPU min 0% | Prevents throttling |
| **GPU** | HAGS on (HwSchMode=2), Game thread high priority | Lower GPU overhead |
| **Xbox** | Disable 4 services + Game Bar + Game DVR | Removes common stutter source |
| **Intel DSA** | Disable DSAService + DSAUpdateService | Free cycles on gaming box |
| **SysMain** | Disable (not needed on SSD) | Less disk I/O |
| **Search** | Disable Windows Search indexer | Less CPU/RAM |
| **Print Spooler** | Disable (no printer attached) | Less CPU/RAM |
| **Hibernation** | `powercfg -h off` | Frees GB of disk |
| **Network** | DNS → Cloudflare 1.1.1.1, Nagle off, TCP tune | Lower latency |
| **Visuals** | Mouse accel off, Fullscreen optimizations off | Better aim, alt-tab |
| **OS noise** | Telemetry basic, tips/ads off, background apps block, P2P update off | Less overhead |
| **Cleanup** | Temp folders, Prefetch, Disk Cleanup | Free space |

### 3b. Optimizations — Phase 2 (Deeper OS-Level Tweaks)

Apply after Phase 1, cross-referenced from community scripts:

| Category | Action | Est. FPS Impact | Source |
|---|---|---|---|
| **VBS** | Disable Virtualization-Based Security + Memory Integrity | +2-5% | PerfGamer, GamingFocus |
| **HPET** | Disable High Precision Event Timer (Device Manager + bcdedit) | 0-10% variable | PerfGamer, Reddit |
| **Network** | `NetworkThrottlingIndex=0xFFFFFFFF`, `SystemResponsiveness=0` | Frame consistency | PerfGamer |
| **Adapter** | Disable EEE, Green Ethernet, power saving on NIC | Latency | GamingFocus |
| **CPU** | Win32PrioritySeparation=38, scheduling → Programs | Smoothness | GamingFocus |
| **Kernel** | Reduce DMA/kernel mitigations (FeatureSettingsOverride=3) | 0-3% | GamingFocus |
| **Power** | Disable power throttling via registry | Prevents drops | Chris Titus |
| **Visuals** | Animations OFF, MenuShowDelay=0, Transparency OFF | UI snappiness | Win11Debloat |
| **Aero** | Disable Aero Shake | Prevents accitental minimize | GamingFocus |
| **Access** | Sticky/Filter/Toggle keys OFF | No accidental triggers | Win11Debloat |
| **Search** | Disable Bing web search | Privacy + speed | Win11Debloat |
| **MSI** | MSI Mode for GPU (modern cards already have it) | Marginal | GamingFocus |
| **Cache** | LargeSystemCache=0 (gaming not file serving) | RAM availability | GamingFocus |
| **Defender** | Exclusions for Steam + game folders | Stop real-time scans on game files | Chris Titus |

### 4. Research Sources (Cross-Reference)

When building optimization scripts, cross-reference these community-maintained sources to avoid missing anything:

| Source | Stars | Focus | URL |
|---|---|---|---|
| Chris Titus WinUtil | 56k | Comprehensive tweak presets + installer | https://github.com/ChrisTitusTech/winutil |
| Win11Debloat | 49k | App removal, privacy, Copilot/Recall disable | https://github.com/raphire/win11debloat |
| GamingFocus | 250 | Kernel mitigations, latency, MSI Mode | https://github.com/DaddyMadu/Windows10GamingFocus |
| PerfGamer | — | Impact-estimated tweaks per setting | https://www.perfgamer.com/advanced-windows-11-tweaks-bios-and-registry-hacks-for-gaming-performance/ |

### 5. BIOS-Level Flags (Cannot Do Remotely)

After remote tweaks, tell the user about these:

| Setting | Est. Gain | Notes |
|---|---|---|
| **XMP / DOCP** | +3-15% FPS | Biggest single gainer — RAM at 2133 MHz by default |
| **Resizable BAR** | +2-8% FPS | Needs Above 4G Decoding + ReBAR in BIOS |
| **Disable C-States** | 0-3% (experimental) | Can hurt Ryzen/Intel 12th+ gen; test first |

### 6. Remote Scripting Pattern

**Avoid complex quoting** in single `sshpass ssh "powershell -Command \"...\""` — it breaks on nested quotes, pipes, multi-line. Use this instead:

```bash
# 1. Write .ps1 locally
# 2. scp to Windows
sshpass -p 'PASSWORD' scp /tmp/script.ps1 $USER@$IP:C:/Users/$USER/script.ps1
# 3. Execute
sshpass -p 'PASSWORD' ssh $USER@$IP "powershell -ExecutionPolicy Bypass -File C:/Users/$USER/script.ps1"
```

For **short single commands** with no pipes/complex quoting, inline works:
```bash
sshpass -p 'PASSWORD' ssh $USER@$IP "powershell -Command \"Get-ComputerInfo | Select-Object OsName | Format-List\""
```

For **netsh** and simple native commands, no PowerShell wrapper needed:
```bash
sshpass -p 'PASSWORD' ssh $USER@$IP netsh interface ip set dns name="Ethernet" source=static addr=1.1.1.1 register=primary
```

### 7. Reboot

```bash
sshpass -p 'PASSWORD' ssh $USER@$IP "shutdown /r /t 10"
```

## Pitfalls

- **Host key changes** on dual-boot machines — always clear old key with `ssh-keygen -R` first
- **`powershell -Command` with pipe (`|`)** — the shell may eat the pipe unless the entire PS command is inside one set of quotes on the SSH side
- **`sshpass` stores the password in the shell history** — the `-p 'PASSWORD'` flag is visible in `ps aux`. Acceptable for one-shot remote ops; use key auth for recurring access
- **`Get-CimInstance Win32_VideoController`** can under-report VRAM on NVIDIA cards (reports 4 GB instead of 8 GB on RTX 3070). Verify in NVIDIA Control Panel when in doubt
- **`shutdown /r /t 10`** needs no `-` prefix on Windows. Can fail if user lacks shutdown privilege (usually local admin works)
- **Some registry paths exist only after NVIDIA driver install** — check with `Test-Path` before writes
- **`chimney` is removed** in newer Windows 11 builds (24H2+). Setting it via `netsh int tcp set global` will error — silently catch or skip
- **`disable-pnpdevice` needs `-Confirm:$false`** or it hangs waiting on the prompt
- **`bcdedit /deletevalue useplatformclock`** errors if HPET was never enabled — catch the error silently, it's harmless
- **PowerShell `: ` in string interpolation** breaks on `$var: text` — use `${var}: text` syntax
- **`cleanmgr /sagerun:1`** needs SagerSet pre-configured or does nothing; rely on `Remove-Item` for temp files
- **MSI Mode** is already default on RTX 2000+ / RX 5000+ GPUs; registry path not found = already correct
- **NVIDIA registry path** `HKLM:\SOFTWARE\NVIDIA Corporation\Global\NvCplApi\Pvt\Global` may not exist on some driver versions — check first

## References

- `references/audit-script.ps1` — full system audit script
- `references/tweak-main.ps1` — primary optimization script (services, power, DNS, cleanup)
- `references/tweak-extras.ps1` — GPU scheduling, mouse, TCP, game priority
