Home » Questions » Computers [ Ask a new question ]

When I run an app from the cmd-line, how do I find the exe's path?

When I run an app from the cmd-line, how do I find the exe's path?

When I run an app from the DOS Prompt in Windows, the command in question is often not in the current directory, but is found via the PATH environment variable. What's the quickest way to find the path of the actual EXE that's being run?

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

"On Vista you can type the executable's name in search field in start menu, when it's displayed in results, r-click and select ""Open file location"" from menu.

If the program is still running and you are using Process explorer from Sysinternals you can r-click on executable in the the processes list and select properties. In the Image tab you have path to the executable.

Another way is to use Windows Powershell, use command ""get-command executable"" without quotes and you will get path for the executable you are looking for. Shortcut for the command is gcm, so use like this ""gcm calc"""
Guest [Entry]

"Try the following:

@rem file which.bat (must be placed somewhere in %PATH%)
@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT ""%%~$PATH:i""=="""" echo %%~$PATH:i

When you type which notepad in commandline (cmd.exe):

C:\>which notepad
C:\Windows\System32\notepad.exe"