Equivalent of “which” in Windows Command Shell Pankaj Kumars Weblog

如果想要知道一个程序或命令在Windows操作系统上的全路径,请使用下面这个脚本,它和Linux的which命令一样。

Equivalent of “which” in Windows Command Shell Pankaj Kumars Weblog.

这个脚本的核心语句是 set fullpath=%~$PATH:1, 这是一个DOS批处理命令的modifier的特殊用法,会自动在环境变量中检索参数1并返回第一找到的结果,如果没找到则返回空字符串。(参见:http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true

另外一个选择是安装 gnuwin32 的which实现:

http://gnuwin32.sourceforge.net/packages/which.htm

Share this:
Facebook Linkedin Twitter Digg Email

Leave a Reply