WHERE - Find Executables
Table of Contents
Sometimes you want to know “where is the executable of this command?”
The WHERE command searches for the location of executable files with a given name, based on the directories listed in the PATH environment variable.
Basic Usage
WHERE command_name
Example
where notepad
All paths where an executable named notepad exists are displayed.
It is especially useful for checking which version a command such as python or node refers to in a development environment.
On Windows 10/11, C:\Users\username\AppData\Local\Microsoft\WindowsApps\python.exe may be listed even when Python is not installed. It is only an entry point that opens the Microsoft Store, not a real Python. Check whether the list also contains a genuine installation path such as ...\Python312\python.exe.
In PowerShell, where is an alias of the Where-Object cmdlet, so it does not behave as expected. Run it with the extension, for example where.exe notepad.
WHERE finds files such as executables and scripts. Internal commands built into the command prompt, such as cd and dir, have no executable file and are not found.
Where WHERE Searches
WHERE first searches the current directory, then the directories in the PATH environment variable in order. If you omit the extension, those listed in the PATHEXT environment variable (.exe, .cmd, .bat, and so on) are tried.
Main Options
| Option | Description |
|---|---|
/R directory | Search recursively from the specified directory |
/Q | Show no output; only return an exit code |
/F | Enclose file names in double quotation marks |
/T | Show file size and last modified time |
Recursive Search (/R)
where /R C:\ notepad.exe
Using Wildcards
where /R C:\Scripts *.cmd
Specifying Multiple Patterns or an Environment Variable
You can give several patterns separated by spaces.
where /R C:\Scripts *.cmd *.bat
With the $envvar:pattern format, only the directories listed in that environment variable are searched.
where $PATH:python*
A plain where python searches both the current directory and PATH. This format restricts the search to PATH only.
Showing Size and Date (/T)
where /T notepad
The size is in bytes. The date format depends on your Windows regional settings.
Existence Check (/Q)
With /Q, nothing is displayed and only an exit code is returned. Use it for conditional branching in batch files.
@echo off
where /Q git
IF NOT ERRORLEVEL 1 (
echo Git is installed.
) ELSE (
echo Git was not found. Check your PATH.
)
Practical Example: Checking a Development Environment
@echo off
setlocal EnableDelayedExpansion
echo === Development environment check ===
echo.
for %%T in (git node python java) do (
where /Q %%T
if !ERRORLEVEL! EQU 0 (
echo [OK] %%T
) else (
echo [NG] %%T not found
)
)
endlocal
Because ERRORLEVEL is referenced inside a for loop, delayed expansion (!ERRORLEVEL!) is used.
If no file is found, WHERE displays an error message and returns exit code 1. For other errors, such as invalid syntax, it returns exit code 2.
Summary
| Operation | Command |
|---|---|
| Find a command’s location | where command_name |
| Search recursively | where /R directory name |
| Show size and date | where /T command_name |
| Existence check (silent) | where /Q command_name |