在Windows命令行上是否有等效的“which”? [英] Is there an equivalent of 'which' on the Windows command line?

查看:804
本文介绍了在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命令打印给定命令的完整路径,以轻松找到和修复这些镜像问题。

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 程序, $ c> which ,但它匹配所有类型的文件,而不只是可执行命令。 (它不匹配内置的shell命令,如 cd 。)它甚至会接受通配符,因此其中nt * 找到您的%PATH%中的所有文件以及名称以 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.

请尝试其中/?寻求帮助。

请注意,Windows PowerShell定义其中作为 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天全站免登陆