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.
If you can find a free Pascal compiler, you can compile this. At least it works and shows the algorithm necessary.
I am using GOW (GNU on Windows) which is a light version of Cygwin. You can grab it from GitHub here.
A screenshot of a list of commands included in GOW:
The GnuWin32 tools have
which
, along with a whole slew of other Unix tools.Windows Server 2003 and later (i.e. anything after Windows XP 32 bit) provide the
where.exe
program which does some of whatwhich
does, though it matches all types of files, not just executable commands. (It does not match built-in shell commands likecd
.) It will even accept wildcards, sowhere nt*
finds all files in your%PATH%
and current directory whose names start withnt
.Try
where /?
for help.Note that Windows PowerShell defines
where
as an alias for theWhere-Object
cmdlet, so if you wantwhere.exe
, you need to type the full name instead of omitting the.exe
extension.