Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the relative order with which Windows search for executable files in PATH?

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.

like image 211
Jeenu Avatar asked Oct 31 '09 05:10

Jeenu


People also ask

What is Windows executable PATH?

The Windows System PATH tells your PC where it can find specific directories that contain executable files. ipconfig.exe , for example, is found in the C:\Windows\System32 directory, which is a part of the system PATH by default.

Does the order of PATH variables matter?

PATH order matters for at least two reasons: If a resource, e.g. a DLL, is in two different versions with the same name, then the one first in path is found and not the second. A program might work with only one particular DLL, or it might work with both. A defective entry in PATH causes all subsequent entries to fail.

How do I find the PATH of an EXE file?

Right-click the “Start” menu shortcut for the application, and select More > Open file location. This will open a File Explorer window that points to the actual application shortcut file. Right click on that shortcut, and select “Properties.” No matter how you located the shortcut, a properties window will appear.

Which searches the PATH variable?

When the user executes a command by using the full path, the shell uses that path to find the command. However, when users specify only a command name, the shell searches the directories for the command in the order specified by the PATH variable.


1 Answers

See the command search sequence on Microsoft Docs

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"

like image 160
mjv Avatar answered Sep 19 '22 01:09

mjv