Skip to content

krypdoh/WinPATH

Repository files navigation

WinPath Manager

A mouse-enabled terminal UI (TUI) tool for managing Windows USER and SYSTEM PATH environment variables on Windows 10/11.

Built with Textual — click buttons, navigate with keyboard shortcuts, or use both.

Python 3.10+ Windows 10/11 License: MIT


Features

Feature Description
Load USER / SYSTEM PATH Read directly from the Windows registry
Duplicate Detection Highlights duplicate entries in yellow
Invalid Path Detection Highlights missing/nonexistent paths in red
Remove Duplicates One-click removal of all duplicate entries
Remove Invalid One-click removal of all missing paths
Move Paths Reorder entries by specifying source and destination positions
Add / Remove Paths Add new entries or remove selected ones with confirmation
Expanded View Toggle to see %VAR% references expanded to their actual values
Save to Registry Write changes back with auto-backup and WM_SETTINGCHANGE broadcast
Backup / Restore Export PATH entries to a text file or restore from one
UAC Elevation Automatically requests admin privileges for SYSTEM PATH saves
Splash Screen ASCII art banner on startup

Screenshots

┌─────────────────────────────────────────────────────────┐
│  WinPath Manager — USER PATH (20 entries)               │
├──────────────┬──────────────────────────────────────────┤
│  ── View ──  │  #  │ Path                    │ Status   │
│ Load USER    │  1  │ C:\Windows\system32     │   OK     │
│ Load SYSTEM  │  2  │ C:\Windows              │   OK     │
│ Refresh      │  3  │ C:\bad\path             │ MISSING  │
│ Expanded     │  4  │ C:\Windows\system32     │   DUP    │
│──────────────│     │                         │          │
│  ── Edit ──  │     │                         │          │
│ Remove Dupes │     │                         │          │
│ Remove Inv.  │     │                         │          │
│ Move a Path  │     │                         │          │
│ Add a Path   │     │                         │          │
│ Remove Sel.  │     │                         │          │
│──────────────│     │                         │          │
│  ── Save ──  │     │                         │          │
│ Save to Reg  │     │                         │          │
│ Backup       │     │                         │          │
│ Restore      │     │                         │          │
│──────────────│     │                         │          │
│  Exit        │     │                         │          │
├──────────────┴──────────────────────────────────────────┤
│ q Quit · u USER · y SYSTEM · Ctrl+S Save · e Expanded  │
└─────────────────────────────────────────────────────────┘

Requirements

  • Python 3.10+ (uses X | Y union syntax)
  • Windows 10 or 11
  • Windows Terminal (recommended — provides the best window size and rendering)
  • Dependencies: textual>=1.0, rich>=13.0 — installed automatically on first run if missing

Installation

Option A — Run from source (requires Python)

No installation needed. WinPath.cmd is a single self-contained file — a polyglot that works as both a Windows batch launcher and a Python script.

  1. Download or clone the repository
  2. Double-click WinPath.cmd from Explorer

On first run, if textual or rich are not installed, WinPath will offer to install them automatically via pip.

Option B — Standalone exe (no Python required)

Build a self-contained executable with PyInstaller:

pip install pyinstaller
pyinstaller --clean --onedir --name WinPath --collect-all textual WinPath.cmd

This produces a dist\WinPath\ folder. Copy that folder anywhere — no Python needed on the target machine. Run dist\WinPath\WinPath.exe directly, or use the included Launch-WinPath.cmd to open it in a properly-sized Windows Terminal window.

Why --onedir? The alternative --onefile bundles everything into a single .exe but extracts to a temp directory on every launch, leaving the launch window visible for ~15 seconds on exit. --onedir has no such overhead.

Usage

Double-click WinPath.cmd from Explorer (source) or Launch-WinPath.cmd (exe build) — either opens a properly-sized Windows Terminal window and launches the app.

To run from a terminal:

# Source
python WinPath.cmd

# Exe build
dist\WinPath\WinPath.exe

Mouse

Click any button in the sidebar to execute that action. Click rows in the path table to select them for removal or inspection.

Keyboard Shortcuts

Key Action
u Load USER PATH
y Load SYSTEM PATH
Ctrl+S Save to registry
e Toggle expanded view
d Remove duplicates
i Remove invalid paths
q Quit

CLI Flags

Flag Description
--save-system <path_string> Internal flag used for elevated SYSTEM PATH writes via UAC

How It Works

  1. Registry Access — Reads/writes HKCU\Environment\Path (USER) and HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path (SYSTEM) using winreg. Preserves the REG_EXPAND_SZ type.

  2. Environment Broadcast — After saving, sends WM_SETTINGCHANGE via SendMessageTimeoutW so running applications pick up the new PATH without a reboot.

  3. UAC Elevation — SYSTEM PATH requires admin. WinPath detects this and re-launches itself elevated via ShellExecuteW("runas", ...) with a --save-system flag to complete the write.

  4. Auto-Backup — Every save automatically creates a timestamped backup file (PATH_USER_20260514_150000_autosave.txt) before writing to the registry.

Project Structure

WinPath/
├── WinPath.cmd            # Single-file launcher + app (polyglot batch/Python) - requires Python
├── winpath.py             # Python-only source (without batch header)
├── Launch-WinPath.cmd     # Launcher for the exe build (opens WT at the right size)
├── WinPath-Launcher.cmd   # Alternative launcher for the exe build
├── winpath-POC.py         # Original CLI proof-of-concept (keyboard only)
├── requirements.txt       # Python dependencies (for manual installs)
├── README.md              # This file
└── index.html             # Product page

How the single-file approach works

WinPath.cmd is a valid Windows batch script and a valid Python script at the same time. The first three lines use the # comment trick:

  • Batch sees: # fails silently, || triggers the real command — opens Windows Terminal at the right size then exits
  • Python sees: lines starting with # are comments — ignored completely, app runs normally

This means you only need to distribute one file.

Author

Paul R. Charovkine — 2026

License

MIT

About

Windows PATH Environment Variable Manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors