How can I print full path of an executable command in Windows?
At the moment when trying to run tf
command and/or any other run-able command, I need to open Visual Studio Command to get it executable. I like to use the normal console and/or the alternative console but failed to call tf
.
So, I need to print the full path of tf
and any runable-command but don't know how to do so.
Please help.
Solution 1:
I'm not really sure what you are asking, but judging by your comments, you may be looking for where
.
where foo
where foo | clip
The second example will place the whole path into the clipboard.
If I remember correctly, where.exe
needs to be added to XP/2003 from the Windows 2003 Resource Kit or XP Support Tools.
Solution 2:
According to Microsoft, you should find tf
in <drive>:\Program Files\Microsoft Visual Studio x\Common7\IDE
.
(I've substituted x in the version because I don't know which version you're using.)
EDIT:
According to the Walkthrough: Working with Team Foundation Source Control from Command Line, (and assuming VS 2005), you can access the tools for TF at the following path:
<drive>:\Program Files\Microsoft Visual Studio 8\Common7\Tools
Solution 3:
where.exe
as mentioned in one of the comments does come with Windows 7 and higher. Another thing to note is that where
only searches the %PATH%
so if your program isn't in the path it won't help you locate it.
Another problem is if you happen to be trying to invoke it from within a PowerShell prompt you NEED to include the .exe portion, as "where" is an alias for Where-Object which is NOT what you want, and leads to empty results with success codes that obviously don't tell you where the application you want is actually located.
This took me a few tries to figure out, and only appending -?
which triggered help on what the alias actually resolved to clued me in.
Per your question, the reason tf
works from within the Visual Studio application/console, there is a specific shortcut they include to launch a Visual Studio console because it adds the application's folders to the PATH when launched.
You can define your own shortcut to inject the program's directory into your PATH
, or just open the Start Menu, type "env" and click the shortcut "Edit environment variables for your account" (or the system one, but that requires you to click on the Environment Variables button), then add a new PATH
variable at the top under User Variables if it doesn't exist, or if it already exists add a ;
before your entry and then the complete folder path where the program you want to call from the command line lives. E.g. double click the PATH
entry (case doesn't matter much on Windows) to edit and change it to C:\ExistingPathItem\bin;C:\Program Files (x86)\Microsoft\Visual Studio 2020\bin