views:

30

answers:

2

If I have a.com, a.cmd, a.bat, and a.exe files %PATH%, which one would Windows pick if I invoke just the command "a"? Is this officially spec-ed somewhere by M$?

I just wanted to wrap my gvim.exe executable with -n, but my gvim.bat doesn't appear to get run neither from the command line, nor from the Run dialog.

+1  A: 

I believe it walks through %PATHEXT% and tries each of those

James Deville
+1  A: 

See the command search sequence on Microsoft Technet

The PATH and PATHEXT environmental variables each provide an element of the search sequence: PATH is the ordered list of directories "where" to look, and PATHEXT is the ordered list of file extensions ("what") to look for (in case the extension isn't explicitly provided on the command line). Prior to using the PATH however, the current directory is searched.

The PATHEXT variable defaults to ".COM;.EXE;.BAT;.CMD"

mjv
I just invoke gvim from Run dialog, and no matter what the PATHEXT is set to, it's only gvim.exe that runs; even if I say gvim.bat at the run dialog.
Jeenu
@Jeenu, this is rather odd. A likely explanation however is that another instance of gvim (or a bat file referencing it) is found before the PATH location where you expect it. Review the path manually, just like the console would do. (or another way to prove this is to temporarily rename the exe in the directory where you think it comes from see whether invoking the command doesn't fail by not finding the exe.
mjv