由于我有时遇到路径问题,其中一个我自己的cmd脚本被另一个程序隐藏(阴影)(在路径的前面),我希望能够在Windows命令行上找到程序的完整路径,给定只是它的名字.
有没有相当于UNIX命令'哪个'?
在UNIX上,which command打印给定命令的完整路径以轻松查找和修复这些阴影问题.
当我where在CMD中运行时,我得到输出:
C:\Users\Ragesh> where calc
C:\Windows\System32\calc.exe
Run Code Online (Sandbox Code Playgroud)
但在PS中同样的事情:
PS C:\data\code> where calc
PS C:\data\code>
Run Code Online (Sandbox Code Playgroud)
输出在哪里?!
当使用命名可执行文件的参数运行时,'which'实用程序将告诉您在路径中找到的具有该名称的第一个可执行文件(如果找到的话).这样可以很好地了解将运行哪个版本的可执行文件.(如果这个描述不完整,请原谅我,但它传达了一般的想法)
我正在寻找'哪个'实用程序的端口,一个Powershell命令,或者其他一些我不知道的实用程序.
我查看了以下SO问题(并将在所选答案中尝试for循环逻辑).我更喜欢有一个实现此功能的命令,并希望查看是否存在.如果不存在这样的东西,那么该逻辑很容易被放入脚本中:
CodeProject上
的"winwhich"实用程序存在.它在6年左右的时间内没有更新,当我在Win 7机器上安装VS 2010时,它在运行时崩溃了.我打算尽职尽责地找出崩溃的原因,但直到今晚才有时间.
有没有人在Windows上使用另一个实用程序或命令来模拟此功能?
我有一个可执行文件名,例如“ cmd.exe”,需要解析它的标准路径。我知道exe出现在PATH环境变量中列出的目录之一中。有没有一种方法可以解析完整路径而无需解析和测试PATH变量中的每个目录?基本上我不想这样做:
foreach (string entry in Environment.GetEnvironmentVariable("PATH").Split(';'))
...
Run Code Online (Sandbox Code Playgroud)
必须有更好的方法,对吗?
我正在使用 PowerShell 并想要执行which命令,但是我看到此错误:
which : The term 'which' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ which xxxxxx
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (which:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
我在谷歌上进行了搜索,但没有针对我的问题的具体答案。以前有人遇到过同样的错误吗?我该如何修复它?
当我在 PowerShell 中输入 python 时,出现如下错误:
Program 'python' failed to execute: The system cannot find the file specified
At line:1 char:11
+ python.exe <<<< .
At line:1 char:1
+ <<<< python.exe
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
Run Code Online (Sandbox Code Playgroud)
我已将 C:\Python27 及其子目录添加到 PATH。我可以通过键入 python.exe 来运行它。可以以相同的方式运行脚本。
我安装了 Python 2.7.11 64 位。