[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

win32ole and WMI question

Barrie Hill

1/3/2009 6:51:00 AM

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
--
Posted via http://www.ruby-....

2 Answers

Heesob Park

1/3/2009 9:47:00 AM

0

Hi,

2009/1/3 Barrie Hill <baz0860@yahoo.com.au>:
> 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.
>

You can call GetOwner method for each process like this:

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

Regards,

Park Heesob

Barrie Hill

1/3/2009 10:58:00 AM

0

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-....