WHERE - Find Executables

Maintained on

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
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>where notepad
C:\Windows\System32\notepad.exe
C:\Windows\notepad.exe
C:\users\user>

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, type where.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.

Internal commands cannot be found

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

OptionDescription
/R directorySearch recursively from the specified directory
/QShow no output; only return an exit code
/FEnclose file names in double quotation marks
/TShow file size and last modified time

Recursive Search (/R)

where /R C:\ notepad.exe

Using Wildcards

where /R C:\Scripts *.cmd
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>where /R C:\Scripts *.cmd
C:\Scripts\backup.cmd
C:\Scripts\cleanup.cmd
C:\Scripts\deploy\setup.cmd
C:\users\user>
おすすめ書籍※ 広告を含む場合があります
中小企業経営者のためのRPA入門 RPA導入を成功させる方法

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

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

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

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

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

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門

Showing Size and Date (/T)

where /T notepad
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>where /T notepad
201216 2024-10-05 14:35:22 C:\Windows\System32\notepad.exe
201216 2024-10-05 14:35:22 C:\Windows\notepad.exe
C:\users\user>

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.

When nothing is found

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

OperationCommand
Find a command’s locationwhere command_name
Search recursivelywhere /R directory name
Show size and datewhere /T command_name
Existence check (silent)where /Q command_name

Quiz

Practice Problem

Which is a correct way to check in a batch file whether a command is available (on the PATH)?

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #WHERE #Command #PATH