Windows 命令行上是否有等价于“which"? [英] Is there an equivalent of 'which' on the Windows command line?

查看:44
本文介绍了Windows 命令行上是否有等价于“which"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我有时会遇到路径问题,其中我自己的一个 cmd 脚本被另一个程序(路径上的早期)隐藏(隐藏),我希望能够在 Windows 命令上找到程序的完整路径行,仅给出其名称.

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.

是否有与 UNIX 命令which"等效的命令?

Is there an equivalent to the UNIX command 'which'?

在 UNIX 上,which command 打印给定命令的完整路径,以便轻松查找和修复这些阴影问题.

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

推荐答案

Windows Server 2003 及更高版本(即 Windows XP 32 位之后的任何内容)提供了 where.exe 程序,该程序执行某些操作 which 可以,尽管它匹配所有类型的文件,而不仅仅是可执行命令.(它不匹配像 cd 这样的内置 shell 命令.)它甚至可以接受通配符,所以 where nt* 可以找到 %PATH%<中的所有文件/code> 和名称以 nt 开头的当前目录.

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.

尝试 where/? 寻求帮助.

请注意,Windows PowerShell 将 where 定义为 Where-Object cmdlet,所以如果你想要where.exe,你需要输入全名而不是省略.exe 扩展名.

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.

这篇关于Windows 命令行上是否有等价于“which"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆