As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name.
Is there an equivalent to the UNIX command ‘which’?
On UNIX, which command prints the full path of the given command to easily find and repair these shadowing problems.
On Windows, you can use the where command to find the full path to a program or script based on its name. The where command searches for executable files in the directories listed in the PATH environment variable.
where
PATH
Here’s an example:
where program_name
Replace program_name with the name of the program or script you are looking for. If the program is found in multiple locations along the PATH, all the matching paths will be displayed.
program_name
For instance:
where notepad
This command will display the full path(s) to the Notepad executable.
If you want to search for a specific file in a specific directory or drive, you can provide the path:
where C:\Path\To\Your\File.exe
Note that the where command supports various options. You can run where /? in the command prompt to see all available options.
where /?