简体   繁体   English

PowerShell中的外部命令-Java

[英]External command in PowerShell - where Java

This works in command prompt: 这在命令提示符下起作用:

where Java

In PowerShell where is an alias for Where-Object . 在PowerShell中whereWhere-Object的别名。 I tried to stop parsing: 我试图停止解析:

--% where Java

This does not work, also tried storing as a variable: 这不起作用,也尝试将其存储为变量:

$StopParser = "--%"
$StopParser where Java

This returns the error: 'Unexpected token 'where' in expression or statement'. 这将返回错误: 'Unexpected token 'where' in expression or statement'.

How can I use the where command in PowerShell? 如何在PowerShell中使用where命令?

This isn't a question of parsing, but of command origins. 这不是解析问题,而是命令来源。 The where cmd command is an executable in System32 that searches your current directory and the PATH environment variable for a pattern: where cmd命令是System32中的可执行文件,可在当前目录和PATH环境变量中搜索模式:

WHERE Java

is equivalent to: 等效于:

cmd.exe /C where.exe Java

The link I provided shows an equivalent command for powershell : 我提供的链接显示了powershell的等效命令:

(Get-Command -Name $file).Definition

or you can alternatively call the executable the same way: 或者,您也可以通过以下方式调用可执行文件:

where.exe Java

For quite a few cmd tools, this is the same paradigm: an executable in System32. 对于许多cmd工具,这是相同的范例:System32中的可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM