Pcornel
Windows · Windows Fundamentals

PATH

Cheat sheet · https://pcornel.dk/topic.php?topic=2934

Back to the Topic

Answer

PATH is an environment variable containing an ordered, semicolon-separated list of directories used during executable/command resolution. The exact resolution algorithm depends on the caller: cmd, PowerShell and application-launch APIs can apply additional rules before or around PATH.

Remember

  • PATH is ordered; an earlier matching executable can shadow a later one.
  • PowerShell can resolve aliases, functions and cmdlets before external applications, so PATH is not its only command-resolution layer.
  • PATHEXT affects extensionless executable lookup in Windows command environments.
  • PATH is inherited through process environment state; newly configured entries may require a new shell/process.
  • Writable or untrusted directories early in PATH can create command-hijacking risk.

First checks

  • $env:Path -split ';' — search directories in order
  • Get-Command <name> -All — every match PowerShell finds
  • where.exe <name> — matches in CMD search order
  • [Environment]::GetEnvironmentVariable('Path','Machine') — machine PATH

Verify in this order

command name → current directory (CMD) / PATH order and PATHEXT → first match executed

Where it usually breaks

First mismatch in target identity/version → persistent configuration/source of truth → provider/service/control plane → runtime/effective state → user/workload-visible result → event/log evidence; preserve identity/native error/pre-state before mutation.

PATH troubleshooting boundaries

BoundaryCheckCommon failure
Process environmentcurrent PATH valueshell inherited stale PATH
Shell resolutionaliases/functions/cmdlets vs external commandPowerShell resolves another command type first
Directory orderfirst matching executableolder copy shadows desired tool
Extension rulesPATHEXT / explicit extensionextensionless command not resolved as expected
Filesystem/accessexecutable exists and can be accessedPATH is correct but file missing/blocked

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2934

Confirmation

Confirm action

Continue?