/commands/cmd/where-find-executable
where: find which executable runs for a command in Windows (like which)
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
- tool
- Command Prompt (cmd)
- versions
- Windows 10, Windows 11, Windows Server 2016+
- os
- windows
where python prints the full path of every file named python plus a PATHEXT extension (.exe, .cmd, .bat …) found in the current folder and then in each PATH folder, in search order. The first line is the one cmd runs. It is the Windows counterpart of which -a. Nothing found prints INFO: Could not find files for the given pattern(s). and sets ERRORLEVEL to 1.
where python
where git node npmExamples
mkdir bin
> bin\tool.cmd echo @echo tool
> notes.txt echo x
where /r . tool.cmd notes.txt
set "PATH=%CD%\bin;%PATH%"
where tool
where /q nosuchtool
echo where /q: ERRORLEVEL=%ERRORLEVEL%
where nosuchtool 2>&1
echo where: ERRORLEVEL=%ERRORLEVEL%Output
/tmp/work/notes.txt /tmp/work/bin/tool.cmd /tmp/work/bin/tool.cmd where /q: ERRORLEVEL=1 INFO: Could not find files for the given pattern(s). where: ERRORLEVEL=1
Options
| Option | Meaning |
|---|---|
| where name | search the current folder and PATH, using PATHEXT when no extension is given |
| where /r folder pattern | search a folder tree recursively instead of PATH |
| where $VAR:pattern | search the folders listed in another variable, for example where $PYTHONPATH:*.py |
| where /q name | quiet: no output, only ERRORLEVEL (0 found, 1 not found) |
| where /t name | also print size, date and time |
| where *.exe | wildcards * and ? are allowed |
Typical uses
- Two versions installed, wrong one runs:
where pythonshows both; the first wins. ReorderPATHor remove the stale entry. The Microsoft Store alias%LOCALAPPDATA%\Microsoft\WindowsApps\python.exeoften appears first. - "is not recognized": if
where namefinds nothing, the program is not in anyPATHfolder; see is not recognized as an internal or external command. - In a batch file:
where /q git || (echo git is required & exit /b 1).
Sources
Related pages
errors · cmd'x' is not recognized as an internal or external command, operable program or batch file.cmd prints this when the name you typed is not a built-in command and no matching .exe, .cmd or .bat exists in the current folder or any PATH directory.commands · cmdAdd a folder to PATH in cmd: set PATH for the session, setx or System Propertiesset PATH=folder;%PATH% changes PATH only for the current cmd window. Make it permanent in System Properties; setx truncates values longer than 1024 characters.errors · powershellPowerShell: The term 'x' is not recognized as the name of a cmdlet, function, script file, or operable programPowerShell found no command by that name: a typo, a module that is not installed, a program not in PATH, or a local script called without its relative path.