通过命令行查询过程 [英] Querying process by CommandLine

查看:44
本文介绍了通过命令行查询过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 WMI 中执行以下查询:

I'm trying to do the following query in WMI:

SELECT ProcessID from Win32_Process where CommandLine='C:\Windows\system32\calc.exe'

但我收到了无效查询"错误.我也试过:

But I got an "Invalid query" error. I also tried with:

SELECT ProcessID from Win32_Process where CommandLine='C:\\Windows\\system32\\calc.exe'

仍然出现相同的错误,我也尝试将单引号更改为双引号,但没有用.

And still get the same error, also I tried to change the single quotes to double quotes but it didn't work.

有人知道是否可以进行该查询吗?

Does anybody know if its possible to do that query?

推荐答案

此外,Windows 有时会在命令行中在 ExecutablePath 之后和第一个之前添加一个额外的 whitespace参数.

In addition Windows adds sometimes an additional whitespace into the command line after the ExecutablePath and before the first parameter.

即使没有参数并且 Executable 用引号引起来(因为路径中有 whitespaces),那么在大多数情况下,命令行是 ExecutablePath 和一个最后的 whitespace 结尾.

Even if there is no paramter and the Executable was lanched with quotes (because of whitespaces in the path) then in most cases the command line is the ExecutablePath and a final whitespace at the end.

我花了几个小时才找到这个.干杯!

That cost me some hours to find this. Cheers!

这篇关于通过命令行查询过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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