Historical Note

This page was migrated from the original p-nand-q.com site which was last updated in 2015. The content has been preserved exactly as it was, with only formatting updated for modern browsers. Over the coming days and weeks, the content will be reviewed and may be updated for accuracy and relevance. If you find any issues, please contact me.

which

This tool locates executable files on the PATH. And it does a lot more. It can be used to determine which executable Windows will call, when multiple copies exist.

Usage

C:\...\>which.exe /?
which - Version 4.0
Freeware written by Gerson Kurz (http://p-nand-q.com)

USAGE: which.EXE [OPTIONS] FILE {FILE}.
OPTIONS:
    /EXTENSION: search for extension , can be a ; separated list
          /DIR: add directory , can be a ; separated list
    /RECURSIVE: search directories recursively
       /SINGLE: stop after the first find result
          /ENV: environment variable, defaults to PATH
   FILE {FILE}: one or more files to find

Examples

To find notepad on the path, try:

C:\...\>which notepad
which - Version 4.0
Freeware written by Gerson Kurz (http://p-nand-q.com)

C:\Windows\notepad.exe [22.08.2013 13:00:12, 217600 bytes]
C:\Windows\SysWOW64\notepad.exe [22.08.2013 05:35:48, 208896 bytes]
C:\Windows\system32\notepad.exe [22.08.2013 13:00:12, 217600 bytes]

Note: You can see from this that on a x64 system, which will show you both 32-bit and 64-bit variants if possible.

Developers will love that which also knows about the environment variables INCLUDE and LIBS. For example, try this:

C:\...\>which windows.h
which - Version 4.0
Freeware written by Gerson Kurz (http://p-nand-q.com)

C:\Program Files (x86)\Windows Kits\8.0\include\um\Windows.h [02.08.2013 17:56:14, 6630 bytes]

You can also use which to list all DLLs starting with "TA" on your path:

C:\...\>which ta*.dll
which - Version 4.0
Freeware written by Gerson Kurz (http://p-nand-q.com)

C:\Windows\SysWOW64\tapi3.dll [22.08.2013 05:46:31, 846336 bytes]
C:\Windows\SysWOW64\tapi32.dll [22.08.2013 05:42:27, 196608 bytes]
C:\Windows\SysWOW64\TapiMigPlugin.dll [22.08.2013 05:38:33, 44032 bytes]
C:\Windows\SysWOW64\tapiperf.dll [22.08.2013 06:04:40, 10240 bytes]
C:\Windows\SysWOW64\tapisrv.dll [22.08.2013 05:33:38, 248320 bytes]
... (lots more omitted here)

Download

License

which is freeware, BSD-licensed.

History


GK, Feb 16, 2014