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
The poster is looking for the equivalent of the "which" command in some Unix shells, e.g. "which grep" prints the full path of the grep command that the shell will execute in response to you typing "grep" without a path. I'm looking for this too. – None – 2011-03-27T06:45:19.050