What is an equivalent of which on the Windows command line?

On the Windows command line, the equivalent of the Linux/Unix “which” command is the “where” command. The “where” command can be used to locate the path of an executable file that is specified in the command line.

For example, if you want to find the path of the “java” executable, you can run the following command:

where java

This will display the full path of the “java” executable file, if it exists in any of the directories that are listed in the system’s PATH environment variable. If the executable file is not found, then the command will not return any output.

The “where” command can also be used with wildcards to search for files that match a specific pattern. For example, to find all executable files that start with the letter “p”, you can run the following command:

where p*.exe

This will display the full path of all executable files that match the pattern “p*.exe”.

Examples

1. Find all files named ‘Zappa’ on the remote computer ‘Server64’ by searching the subdirectories of Share1:

C:\> WHERE /r \\Server64\Share1 Zappa.*

2. List all the files in the Demo folder:

C:\> WHERE "C:\demo\:*.*"

3. List all the .CSV files on both the work and play folders:

C:\> WHERE C:\work\;C:\Play\:*.csv

4. In PowerShell, find all copies of robocopy.exe in the current system path:

PS C:\> WHERE.exe robocopy.exe

Summary

The “where” command in Windows is a command-line utility that helps you locate the path of an executable file that matches the name you specify. It is similar to the Linux/Unix “which” command.

Related Post