Outputs one or more locations of a file or a file name pattern, where the file or pattern does not need to state the extension if it listed in PATHEXT, such as .exe. Searches in the current directory and in the PATH by default. Does some of the job of "which" command of some other operating systems, but is more flexible.
Available on Windows 2003, Windows Vista, Windows 7, and later; not available on Windows XP. An alternative to be used with Windows XP is in the examples below.
Does not find internal commands, as there are no dot exe files for them to match.
Outputs the location of the find command, possibly "C:\Windows\System32\find.exe". The .exe extension does not need to be specified as long as it is listed in PATHEXT, which it is by default.
If there are more find commands in the path, outputs paths to both. In some situations, it can output the following:
for %i in (find.exe) do @echo %~$PATH:i
Outputs the location of "find.exe" on Windows XP. The name has to include ".exe", unlike with the where command.
where /r . Tasks*
Searches for files whose name matches "Task*" recursively from the current folder. Similar to "dir /b /s Tasks*". The /r switch disables search in the folders in PATH.
Outputs all .bat files in the current directory and in the directories that are in PATH. Thus, outputs all .bat files that you can run without entering their full path.
As above, constraining also the beginning of the name of the .bat files.
As above, but with no constraint on the extension. Finds lsdisks.bat, lsmice.pl, and lsmnts.py if in the current directory or in the path.
where *.exe *.com | more
Displays countless .exe and .com files in the path and in the current folder, including those in C:\Windows\System32.
Outputs .bat files in the path but not those in the current folder unless the current folder is in PATH. Instead of path, another environment variable containing a list of directories can be used.
Outputs .exe files found in the folder stated in WINDIR environment variable.
where $path:*.bat $windir:*.exe
A combination is possible. Outputs all files matching either of the two queries.
where /q *.bat && echo Found
Suppresses both standard and error output, but sets the error level, enabling testing on it. The error level is set either way, with or without /q.
$ where /? WHERE [/R dir] [/Q] [/F] [/T] pattern... Description: Displays the location of files that match the search pattern. By default, the search is done along the current directory and in the paths specified by the PATH environment variable. Parameter List: /R Recursively searches and displays the files that match the given pattern starting from the specified directory. /Q Returns only the exit code, without displaying the list of matched files. (Quiet mode) /F Displays the matched filename in double quotes. /T Displays the file size, last modified date and time for all matched files. pattern Specifies the search pattern for the files to match. Wildcards * and ? can be used in the pattern. The "$env:pattern" and "path:pattern" formats can also be specified, where "env" is an environment variable and the search is done in the specified paths of the "env" environment variable. These formats should not be used with /R. The search is also done by appending the extensions of the PATHEXT variable to the pattern. /? Displays this help message. NOTE: The tool returns an error level of 0 if the search is successful, of 1 if the search is unsuccessful and of 2 for failures or errors. Examples: WHERE /? WHERE myfilename1 myfile????.* WHERE $windir:*.* WHERE /R c:\windows *.exe *.dll *.bat WHERE /Q ??.??? WHERE "c:\windows;c:\windows\system32:*.dll" WHERE /F /T *.dll