How to Locate Executables and Script Paths in Windows 11 Using the where Command

Resolving Program Paths and Command Collisions in Windows 11

When running command-line utilities, configuring developer build tools, managing Python or Node.js environments, or writing PowerShell and batch scripts in Windows 11, invoking an executable name (such as python, git, or node) instructs the operating system to scan through directories listed in your system PATH environment variable. However, when multiple versions of a tool are installed—for example, when a Python interpreter is installed via the Microsoft Store, another via Anaconda, and a third via an official Windows installer—determining which exact executable file is actually executing can be confusing. Windows 11 includes a native, built-in command-line utility called where. Operating identically to the classic which command in Linux and macOS, where instantly locates and displays the full absolute file system paths of all matching executables, scripts, and batch files.

Basic Syntax and Default Behaviour

The where command works out of the box in both Command Prompt (cmd.exe) and Windows Terminal (PowerShell):

where [options] pattern

When you execute where followed by an executable name:

where git

The utility outputs the complete absolute path of the program:

C:\Program Files\Git\cmd\git.exe

If multiple instances of an executable exist across your system directories, where lists every single match in the exact order of precedence that Windows evaluates them, making it effortless to identify path shadowing bugs.

Using where in PowerShell vs Command Prompt

An essential tip for PowerShell users is that PowerShell includes a built-in alias where that maps to the Where-Object cmdlet. If you are typing inside PowerShell, running bare where without arguments can result in a syntax parsing error.

To explicitly invoke the Windows command-line utility inside PowerShell, execute:

where.exe python

Alternatively, invoke Command Prompt directly, where where functions natively without requiring the .exe file extension.

Searching with Wildcards and Matching File Extensions

The where utility natively supports wildcard syntax (* and ?), allowing you to locate utilities even if you only remember a prefix or partial name:

where.exe code*

This searches for any executable starting with “code” across your PATH (returning entries such as code.cmd, code.exe, or codex.exe).

By default, where appends the extensions defined in your system’s PATHEXT variable (including .COM, .EXE, .BAT, .CMD, .VBS, .JS, and .PS1). If you wish to locate non-executable file types or specific configuration templates, explicitly append the target extension:

where.exe config.json

Searching Specific Directories Recursively with /R

By default, where confines its lookup to your current working directory and the directories declared in your PATH variable. If you want to search an entire storage drive or project directory tree recursively, use the /R parameter:

where /R C:\Users\Username *.ps1

This scans all subfolders beneath the specified root directory and lists the full path of every PowerShell script discovered.

Displaying File Sizes and Modification Timestamps with /T

When diagnosing whether an executable has been updated by a recent patch or inspecting multiple binary versions, viewing file metadata directly in the terminal saves substantial time. Append the /T switch:

where.exe /T python

The command outputs a structured table displaying:

  • The exact file size in bytes.
  • The last modified date and timestamp.
  • The full absolute file path.

Validating Tool Availability in Shell Scripts with /Q

If you are writing batch or PowerShell setup scripts that require pre-requisite tools before continuing, use the /Q (quiet) flag. This suppresses all console output and sets the process exit code (ERRORLEVEL) to 0 if the file was found, or 1 if absent:

where.exe /Q docker
if ($LASTEXITCODE -eq 0) {
    Write-Host "Docker is installed and ready."
} else {
    Write-Warning "Docker could not be found in PATH."
}

Mastering the where.exe utility provides immediate transparency into system PATH resolutions, preventing compiler mismatch issues and version conflicts across your Windows 11 environment.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.