Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > win32ole and WMI question

Reply
Thread Tools

win32ole and WMI question

 
 
Barrie Hill
Guest
Posts: n/a
 
      01-03-2009
Hi,

I am trying to get process information from Windows server. Using
examples I have found on the web and in documentation I have come up
with the following script.

require 'win32ole'

wmi = WIN32OLE.connect("winmgmts://")

processes = wmi.ExecQuery("select * from win32_process")

for process in processes do
process_list = {process.ProcessId =>
"#{process.ProcessId}:#{process.CreationDate}:#{pr ocess.WorkingSetSize}:#{process.KernelModeTime}:#{ process.UserModeTime}"}
p process_list
end

I would like to be able to call the Win32_Process.GetOwner method from
the WMI class and include the process owner in the output of the above
script.

I would appreciate any assistance.

Thanks.

Cheers, Barrie
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Heesob Park
Guest
Posts: n/a
 
      01-03-2009
Hi,

2009/1/3 Barrie Hill <>:
> Hi,
>
> I am trying to get process information from Windows server. Using
> examples I have found on the web and in documentation I have come up
> with the following script.
>
> require 'win32ole'
>
> wmi = WIN32OLE.connect("winmgmts://")
>
> processes = wmi.ExecQuery("select * from win32_process")
>
> for process in processes do
> process_list = {process.ProcessId =>
> "#{process.ProcessId}:#{process.CreationDate}:#{pr ocess.WorkingSetSize}:#{process.KernelModeTime}:#{ process.UserModeTime}"}
> p process_list
> end
>
> I would like to be able to call the Win32_Process.GetOwner method from
> the WMI class and include the process owner in the output of the above
> script.
>
> I would appreciate any assistance.
>


You can call GetOwner method for each process like this:

ret = process.execMethod_('GetOwner')
p ret.User
p ret.Domain

Regards,

Park Heesob

 
Reply With Quote
 
 
 
 
Barrie Hill
Guest
Posts: n/a
 
      01-03-2009
Hi Heesob,

> You can call GetOwner method for each process like this:
>
> ret = process.execMethod_('GetOwner')
> p ret.User
> p ret.Domain


Thank you for your help. It is exactly what I wanted. I spent a few
hours trying to work out how to use GetOwner.

Cheers, Barrie
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WMI and WIN32OLE issues Spike Ruby 0 10-26-2006 06:07 PM
WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later) Masaki Suketa Ruby 4 03-27-2006 11:17 AM
Using Win32OLE, WMI and ExecMethod Daniel Berger Ruby 1 06-04-2004 05:18 AM
Segfault with win32ole, WMI and structs Daniel Berger Ruby 4 05-24-2004 12:53 AM
Ruby.exe crashing with WIN32OLE WMI example? yonatan Ruby 0 01-06-2004 07:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57