Linux has a which command to find the location of the executable file.
For example:whichfind, which searches for the command from the path of a path variable, returns the result of the first match found.
So we can see where we are using the find program.
Windows does not have such an instruction, we can write it ourselves:
@echo Offecho%~dp$path:1@echo on
That's three lines!
Here is the result of the execution
D:\work\rf>d:\which.bat Java.exe
C:\Program files\java\jdk1.7.0_71\bin\
D:\work\rf>d:\which.bat cmd.exe
C:\WINDOWS\system32\
D:\work\rf>d:\which.bat cl.exe
C:\Program Files\Microsoft Visual Studio\vc98\bin\
This must write the full file name, without the extension is not possible.
Here is an extension of the batch-processing editor, which is referenced from the Windows Help file :
You can also use an edit character in a batch parameter. The editor uses the current drive and directory information to extend the batch parameter to a partial or complete file or directory name. To use the edit character, type the percent sign (%) character, followed by the tilde (~) character, and then type the appropriate editor (that is,%~modifier).
%~ $PATH: 1 searches the directory listed in the PATH environment variable and expands%1 to the fully qualified name of the first found directory. If the environment variable name is not defined or the file is not found, the editor expands to an empty string.
The which command for Windows