The where command in Windows is a command-line tool that searches your system's PATH folders and tells you the full location of an executable file. If you type where notepad in Command Prompt, Windows replies with the exact folder path of notepad.exe — usually C:\Windows\System32\notepad.exe or the packaged Windows app version. That is the whole job: it answers "where is this program actually stored?" It is the Windows equivalent of the Unix which command, and it also works for any kind of file when you give it a pattern.
You do not need to install anything. where is built into Windows and runs from Command Prompt, PowerShell and Windows Terminal. The basic form is one line: open a terminal, type where programname, press Enter. Everything below explains the options, the edge cases and what to do when the answer comes back empty.
What You'll Need
- A Windows PC with Command Prompt or PowerShell available (both are preinstalled).
- No administrator rights for ordinary searches. A few protected folders may return "Access denied" without elevation.
- The name of the program or file you are looking for, without the
.exeextension if you like —where chromeandwhere chrome.exeboth work. - Optional: a terminal you can open in a specific folder, so you can search that folder instead of the whole PATH.
Step-by-Step
- Open a terminal. Press
Win+R, typecmdand press Enter to get Command Prompt, or right-click the Start button and choose Windows Terminal or PowerShell. Menu labels shift slightly between Windows versions and builds, so the wording on your machine may differ a little. - Run the basic query. Type
where notepadand press Enter. You get one or more full paths, one per line. If more than one path appears, Windows found several matches — often one underC:\Windows\System32and another underC:\Windows\System32\WindowsPowerShellor a packaged app alias folder. The first result is the one that runs when you type the bare name, because Windows uses PATH order. - Search for a file type, not just executables. By default
whereonly looks for executable extensions. To search for any file, use a wildcard inside the search pattern:where /r C:\Users\YourName\Documents *.pdf. This walks the whole folder tree and lists every PDF. You can also combine extension filters with/fand a type name, such as a document type, but the wildcard form is the one that behaves the same everywhere. - Search a specific folder instead of PATH. Add
/rfollowed by a folder to search recursively from that starting point:where /r C:\ProgramData *.ini. Without/r,wherechecks the current directory and the PATH folders only. This is the difference people trip over most. - Make the output readable. Use
where /t programnameto show the file size and timestamp next to each path, andwhere /q programnamefor a quiet check that returns only an exit code — handy inside batch scripts where you want to test whether a tool exists without printing anything. - Read the exit code. After the command finishes, type
echo %errorlevel%in Command Prompt. A result of0means at least one match was found;1means nothing matched. In PowerShell use$LASTEXITCODEinstead. This is how you confirm a program exists before calling it in a script. - Try the PowerShell alternative if you want more control.
Get-Command notepadshows the command type and path, andGet-Command -All notepadlists every match. For files rather than commands,Get-ChildItem -Recurse -Filter *.logfrom a folder does the same job aswhere /r.
Common Mistakes
Expecting a full-drive search. where does not search your entire hard drive. It searches the current folder and the folders listed in the PATH environment variable — nothing else. If your program lives in D:\Tools and that folder is not on the PATH, plain where will not find it. Add /r D:\Tools or add the folder to PATH.
Forgetting the wildcard. Running where report.docx returns nothing because the file is not on the PATH. Running where /r C:\Users *.docx works because /r plus a pattern tells it where to look and what to match.
Quoting paths with spaces. Folder names with spaces need quotes: where /r "C:\Program Files" *.dll. Unquoted, the command treats each word as a separate argument.
Typing it as which. which is not a Windows command. In PowerShell, which is not recognized either — though Get-Command is. Some third-party terminal environments add their own aliases, but native Windows does not have one.
Confusing the result with the running process. where finds files on disk. To see what is actually running, use Task Manager or tasklist. A program can be installed in several places while only one copy is live.
Tips
- Pipe the output to a file when the list is long:
where /r C:\Users *.jpg > C:\Users\YourName\Desktop\found.txt. - Use
where /r .to search from the folder you are currently in — faster than naming an absolute path each time. - If you are hunting for a program shortcut rather than the program, search for
*.lnkin your Start Menu folders instead; Start Menu shortcuts point to the real executable, and you can read the target from the shortcut's properties. - Remember that PATH order matters. Two copies of the same tool can exist, and the first PATH entry wins — this is the usual cause of "it runs an old version" problems.
Troubleshooting
The command says "INFO: Could not find files for the given pattern(s)." That is the standard not-found message. Check the spelling first, then confirm the program actually exists, then widen the search with /r and a folder you know contains it. If the file is in a folder you use often, adding that folder to the PATH environment variable makes future where calls succeed without /r.
"Access is denied" lines appear. Some system or user-profile folders restrict listing. Running the terminal as administrator resolves most of these, but it is not necessary for ordinary program lookups — just note that some results may be hidden.
The search is very slow. A recursive search over a large drive scans every subfolder. Point /r at a narrower folder, or use PowerShell's Get-ChildItem with an include filter to skip what you do not need.
PowerShell says the term is not recognized. where is a Command Prompt utility. PowerShell can usually call it, but some environments block it because where conflicts with the Where-Object alias where. If that happens, use where.exe notepad to force the executable, or use Get-Command.
Frequently Asked Questions
Does where work for folders as well as files?
Not directly. It reports files matching a pattern. To list folders with a given name, use dir /s /b /ad with a matching pattern, or PowerShell's Get-ChildItem -Directory -Recurse.
Can I use wildcards with where?
Yes, in the search pattern — for example where /r C:\Users *.cfg. Wildcards are not needed in the plain executable search.
What is the difference between where and Get-Command?
where finds files on disk. Get-Command lists the commands PowerShell can run, including aliases, functions and cmdlets, not just executables. Use Get-Command when you want to know what a typed name resolves to inside PowerShell.
Why does where return two paths for one program?
Because two copies exist in different PATH folders. Windows runs the first one listed. This commonly happens after an upgrade leaves the old version behind.
Does it need administrator rights?
No, not for normal program lookups. Elevation only helps when part of the search tree is protected.
Can I use it in a batch file?
Yes. where /q tool.exe sets the error level so your script can branch, and where tool.exe prints the path if you want to log it.