检查进程是否为插件

问题描述:

如果名为“jp2launcher”的进程是插件,我想检查Powershell。我有以下命令的命令行:检查进程是否为插件

wmic process where (name="jp2launcher.exe") get CommandLine 

这个命令的结果是:

"C:\Program Files (x86)\Java\jre1.8.0_31\bin\jp2launcher.exe" -secure -plugin ... 

所以,如果有-plugin的过程是一个插件。有没有办法只选择插件的进程?

+1

也许我误解你的问题,但你不能只筛选命令? Get-WmiObject Win32_Process |其中{$ _。CommandLine -n​​e $ null - 和$ _。CommandLine.Contains(“ - plugin”)} | select commandline –

+0

这对我很好,但我必须在名称“jp2launcher”上设置选择? –

有没有办法只选择插件的进程?

这将查询WMI与命令行匹配字符串“-plugin”过程(和选择字段名称和唯一的CommandLine):

Get-WmiObject Win32_Process | Where CommandLine -match "-plugin" | Select Name, CommandLine

如何我现在只选择过程称为“jp2launcher”,以及如何将其进程ID保存到变量中?

Get-WmiObject Win32_Process | Where CommandLine -match "-plugin" | Where Name -match "jp2launcher" | Select Name, CommandLine

+0

我现在该如何选择被称为“jp2launcher”的进程,以及如何将其进程ID保存到变量中? –

+1

根据您的要求添加了另一个示例。我以为你想要名称和命令行匹配。 – sodawillow

+0

谢谢,它的作用就像你的第二个例子 –