小能豆

Is there an equivalent of 'which' on the Windows command line?

javascript

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.


阅读 222

收藏
2023-12-27

共1个答案

小能豆

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.

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.

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.

2023-12-27