Is there an equivalent of ‘which’ on the Windows command line?

As I sometimes have path problems, where one of my own cmd scripts is hidden (shadowed) by another program (earlier on the path), I would like to be able to find the full path to a program on the Windows command line, given just its name.

Is there an equivalent to the UNIX command ‘which’?

On UNIX, which command prints the full path of the given command to easily find and repair these shadowing problems.

2
26

Windows Server 2003 and later (i.e. anything after Windows XP 32 bit) provide the where.exe program which does some of what which does, though it matches all types of files, not just executable commands. (It does not match built-in shell commands like cd.) It will even accept wildcards, so where nt* finds all files in your %PATH% and current directory whose names start with nt.

Try where /? for help.

Note that Windows PowerShell defines where as an alias for the Where-Object cmdlet, so if you want where.exe, you need to type the full name instead of omitting the .exe extension. Alternatively, you can set an alias for it:

Set-Alias which where.exe

Update: Using Get-Command (alias: gcm) is recommended since it’s native to PS and will get all command types: aliases, cmdlets, executables, and functions. Example:

gcm notepad*

Leave a Comment