A sibling .exe silently beats your .cmd shim — PATHEXT rank order
env paths · case
Affectsnode, powershell 51, pwsh 7, windows, win32 api
Fails assilent
Mechanismpathext resolution
Safe fixshim all siblings
Symptom
Section titled “Symptom”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.
$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.
Workaround
Section titled “Workaround”- Shim ALL launchable siblings (or rename/refresh the
.exetoo, as the referenced fix does). - Detection: after installing a shim, resolve the bare name again and verify it lands on your shim.