Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pathutil

A tiny Windows PATH environment-variable manager written in Go.

It reads and writes the PATH directly from the Windows registry (so changes persist across reboots) and broadcasts WM_SETTINGCHANGE so newly launched processes pick up the change immediately.

Features

  • 📋 list — show all PATH entries (user and/or machine scope)
  • add / ➖ delete — append/remove an explicit directory
  • register / unregister — add/remove the current directory (just cd somewhere and run pathutil register)
  • 🔍 where — check which scope a directory is present in
  • Case-insensitive matching (Windows paths), idempotent operations
  • Persists to registry + notifies the system; no re-login needed for new shells

Install

Download the latest binary from the Releases page, or build from source:

go build -o pathutil.exe .

Usage

pathutil - Windows PATH management

Usage:
  pathutil list                          List all PATH entries (user + machine)
  pathutil add <dir> [--scope machine]   Append a directory to PATH
  pathutil delete <dir> [--scope machine]  Remove a directory from PATH
  pathutil where [<dir>]                 Check where a directory is present
  pathutil register [--scope machine]    Add the CURRENT directory to PATH
  pathutil unregister [--scope machine]  Remove the CURRENT directory from PATH

Options:
  --scope user|machine   Target scope (default: user). "machine" needs admin.

Examples

# List everything
pathutil list
pathutil list --scope machine

# Add / remove an explicit directory
pathutil add C:\Tools\bin
pathutil delete C:\Old\Path

# The convenient form: cd into a project, then register it
cd D:\Projects\mytool
pathutil register          # now `mytool` is on PATH
pathutil unregister        # take it off again

# Where is Go's bin?
pathutil where C:\Go\bin

Notes

  • Changes only affect newly launched processes. The terminal you ran the command in keeps its old environment — open a new one to see the update.
  • --scope machine writes to HKLM\...\Environment and requires the shell to be elevated (Run as administrator). If not elevated, pathutil prints a clear message and exits with code 7.
  • User scope writes to HKCU\Environment and needs no special privileges.

How it works

pathutil opens the Windows registry key that stores PATH:

Scope Registry key
user HKEY_CURRENT_USER\Environment
machine HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

It splits the value on ; (ignoring empty entries), performs the add/remove case-insensitively, writes the value back, then broadcasts WM_SETTINGCHANGE with lParam = "Environment" so Explorer and other apps reload their environment.

Build

Requires Go 1.25+ and GOOS=windows (it uses the golang.org/x/sys/windows/registry package).

go build -o pathutil.exe .

Releases are produced automatically by the GitHub Actions workflow on every version tag (e.g. v0.1.0) for windows/amd64 and windows/arm64.

License

MIT

About

A small Go CLI for managing the Windows PATH environment variable via the registry.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages