Skip to content

A sibling .exe silently beats your .cmd shim — PATHEXT rank order

env paths · case

bothsilentscriptagentfirst-partyrepro: verifiedpathext-resolution
Affectsnode, powershell 51, pwsh 7, windows, win32 api
Fails assilent
Mechanismpathext resolution
Safe fixshim all siblings

A wrapper that rewrites tool.cmd works for months. Then an updater drops tool.exe in the SAME directory and every invocation silently bypasses the wrapper — no error, just the unwrapped binary running.

Terminal window
$env:PATHEXT # .COM;.EXE;.BAT;.CMD;... ← .EXE outranks .CMD
# dir with both tool.exe and tool.cmd → "tool" resolves to tool.exe, always.

PATHEXT is an ordered list. Extensionless resolution tries .COM, then .EXE, then .BAT/.CMD — within the same PATH entry. A shim strategy that only owns the .cmd name is one updater run away from being invisible.

  • Shim ALL launchable siblings (or rename/refresh the .exe too, as the referenced fix does).
  • Detection: after installing a shim, resolve the bare name again and verify it lands on your shim.