0

我需要执行以下操作:

  1. 启动火狐
  2. 加载包含一些插件内容的页面
  3. 查找插件进程的processID
  4. 使用 processID 将 cdb 附加到插件进程
  5. 检测插件加载的 DLL

为了使用批处理脚本自动执行此操作,我需要一种方法来查找给定进程名称的 processID。有没有办法做到这一点?

4

1 回答 1

2

You could use wmic to return that: wmic process where name="cmd.exe" get processid gets you pids of all cmd.exe running.
Assuming you do not know full process name (is that's why you could not use cdb -pn?) you could also use like:
wmic process where 'name like "%cmd%"' get processid will get everything with cmd anywhere in it's name. It's also possible to use other SQL wildcards.

To see what properties you can query, open wmic (just do wmic from command line) and issue process get /?

Note: wmic produces output in Unicode and attaches double <CR> to it's output lines. This sometimes requires special attention and handling in your batch.

于 2012-09-18T09:19:28.553 回答