WHERE - Find Executables
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.
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

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超 入門

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
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 |