使用WMI获取windows进程信息
程序员文章站
2022-03-03 13:50:12
...
本例主要实现如何用WMI(Windows Management Instrumentation )获取windows进程信息。
首先,需要用到win32ole。
require 'win32ole'
具体实现:
wmi = WIN32OLE.connect("winmgmts://")
processes = wmi.ExecQuery("select * from win32_process")
processes.each do |process|
puts "Name: #{process.Name}"
puts "CommandLine: #{process.CommandLine}"
puts "CreationDate: #{process.CreationDate}"
puts "WorkingSetSize: #{process.WorkingSetSize}"
puts
end
示例输出:
Name: System Idle Process
CommandLine:
CreationDate:
WorkingSetSize: 28672
Name: System
CommandLine:
CreationDate:
WorkingSetSize: 311296
Name: smss.exe
CommandLine: \SystemRoot\System32\smss.exe
CreationDate: 20100108194948.296875+480
WorkingSetSize: 835584
Name: csrss.exe
CommandLine:
CreationDate: 20100108194952.468750+480
WorkingSetSize: 12623872
Name: winlogon.exe
CommandLine: winlogon.exe
CreationDate: 20100108194954.437500+480
WorkingSetSize: 31866880
上一篇: jupyter notebook oepncv 显示一张图像
下一篇: 格式化或删除的文件 恢复