On Windows 10, I have a file called
truffle.jsin my current folder.I writetrufflein the cmd window, expecting to invoke thetruffleprogram which resides elsewhere on my path.Instead,
truffle.jsis opened in my favorite IDE (.jsfiles are associated with that IDE). I thought this behavior is only like this for executable files,.bat,.comand.exe. Why does it happen for a.jsfile?Note: I subsequently discovered I have no
truffleat all installed on my path, but my question remains: why is Windows completing the extension which I did not specify on a non-executable file?Even after installing truffle and restarting cmd, I can’t get the real truffle to run in a folder that contains a file
truffle.js.
Solution:
Because %PATHEXT% is set to .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC by default. Note how it contains .js.
That means if you type a name, CMD will look for files with these extensions appended, in that order, in the current folder. Only after that will it consider what’s in %PATH%. This behavior cannot be changed. You can modify %PATHEXT% though, like any other environment variable.
You can use the WHERE command to check which path would be opened (e.g. where truffle), which will automatically search both %PATH% and %PATHEXT% the same way CMD would.

