Forum: Ruby win32ole and WMI question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Abe425ab8d5fb3b7191ea6eb46973c2e?d=identicon&s=25 Barrie Hill (baz0860)
on 2009-01-03 07:51
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}:#{process.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
666b4e17b4bb0e2d999037a25f65a7cb?d=identicon&s=25 Heesob Park (phasis)
on 2009-01-03 10:48
(Received via mailing list)
Hi,

2009/1/3 Barrie Hill <baz0860@yahoo.com.au>:
>     processes = wmi.ExecQuery("select * from win32_process")
>
> 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
Abe425ab8d5fb3b7191ea6eb46973c2e?d=identicon&s=25 Barrie Hill (baz0860)
on 2009-01-03 11:58
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
This topic is locked and can not be replied to.