# Re: Getting a list of Processes

**URL:** <https://www.ruby-forum.com/t/re-getting-a-list-of-processes/63097>\
**Category:** Ruby\
**Created:** [June 12, 2006, 4:20am UTC](https://www.ruby-forum.com/t/re-getting-a-list-of-processes/63097 "2006-06-12T04:20:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 12, 2006, 4:20am UTC](https://www.ruby-forum.com/t/re-getting-a-list-of-processes/63097/1 "2006-06-12T04:20:28Z")

</div>

fr Brad:

# Sure, no problem… also, you can list more than the process name. I

# like to show the PID and the executablepath, etc. Here are

# other process

# items you might like to examine:

# 

# class Win32\_Process : CIM\_Process

# {

# string Caption;

# string CommandLine;

# …

it would be nice if a particular ruby win32ole method can expose all  
those attributes without looking thru msdn docs, no? similar to an ole  
browser yet in ruby lib format…

thanks and kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 12, 2006, 1:28pm UTC](https://www.ruby-forum.com/t/re-getting-a-list-of-processes/63097/2 "2006-06-12T13:28:00Z")

</div>

PeÃ±a, Botp wrote:

> it would be nice if a particular ruby win32ole method can expose all  
> those attributes without looking thru msdn docs, no? similar to an ole  
> browser yet in ruby lib format…
> 
> thanks and kind regards -botp

I agree. I do it in Python (with the wmi module) like this:

c = wmi.WMI()  
for item in c.Win32\_Process():  
print item

I don’t know who to contact about it. Is there a formal request process  
for Ruby additions someplace?

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [June 13, 2006, 8:41am UTC](https://www.ruby-forum.com/t/re-getting-a-list-of-processes/63097/3 "2006-06-13T08:41:39Z")

</div>

PeÃ±a, Botp wrote:

> fr Brad:
> 
> # Sure, no problem… also, you can list more than the process name. I
> 
> # like to show the PID and the executablepath, etc. Here are
> 
> # other process
> 
> # items you might like to examine:
> 
> # 
> 
> # class Win32\_Process : CIM\_Process
> 
> # {
> 
> # string Caption;
> 
> # string CommandLine;
> 
> # …
> 
> it would be nice if a particular ruby win32ole method can expose all  
> those attributes without looking thru msdn docs, no? similar to an ole  
> browser yet in ruby lib format…

Here it is…I think this is what you were looking for.  
It displays all of the properties for a WMI Class.

require ‘win32ole’

class MyClass  
def get\_process\_info()  
procs = WIN32OLE.connect(“winmgmts:\\.”)  
rst = procs.ExecQuery("SELECT \* FROM meta\_class WHERE _class =  
‘Win32\_Process’")  
rst.each do |x|  
puts x.path.Class.to\_s #The Class Name  
x.properties_.each do |m|  
puts " " + m.Name.to\_s #Available Properties of this Class  
end  
end  
end  
end

a = MyClass.new  
a.get\_process\_info()
