Home » Questions » Computers [ Ask a new question ]

Dos executable lookup except PATH

Dos executable lookup except PATH

I have a cmd open (Windows 7), and I type "java.exe", and the system finds the executable at c:\program files\java\jre6\bin.

Asked by: Guest | Views: 267
Total answers/comments: 2
Guest [Entry]

"Starting with Vista and above, Windows now includes a utility called where. This program functions just like you'd expect the unix counterpart to (I'm glad they added it!)

Usage:

C:\>where java
C:\Windows\System32\java.exe

What's even nicer about where is that it'll show you all executables it finds within your path, so if you also had java.exe in C:\Windows it would show up under the \System32\ one.

EDIT

I figured I'd also include an option for XP users that would like the functionality without third party tools. Raymond Chen wrote a command script in A 90-byte ""whereis"" program. It's a nice one liner that accomplishes the same task!

@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT ""%%~$PATH:i""=="""" echo %%~$PATH:i

Save the above script in a .bat or .cmd file and you can launch it from the command line with the filename as the argument. It'll work just like you expect! (note, if using the script version, leave off the extension, it'll search all executable extensions for you)"
Guest [Entry]

"There is an another way to look up files location in path using powershell:
(Get-Command java).Source"