WHERE - Find Executables

Maintained on
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

Syntax
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.

Tip

It is especially useful for checking which version a command such as python or node refers to in a development environment.

When Python is listed but does not run

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, 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)

Search
where /R C:\ notepad.exe

Using Wildcards

Find
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>

Specifying Multiple Patterns or an Environment Variable

You can give several patterns separated by spaces.

Find
where /R C:\Scripts *.cmd *.bat

With the $envvar:pattern format, only the directories listed in that environment variable are searched.

Search
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
- □ ×
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.

Check
@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

check_tools.cmd
@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)?

Choose one answer.

  1. Run where /Q command_name and check ERRORLEVEL
  2. Run where /E command_name
  3. Run where /CHECK command_name
#Command Prompt #Batch File #WHERE #Command #PATH