Re: Need some help using Win32_Process.GetOwner() from JScript

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Gerry Hickman (gerry666uk_at_yahoo.co.uk)
Date: 09/23/04


Date: Thu, 23 Sep 2004 21:12:00 +0100

Hi Swoop,

> Actually, I figured it out. go me. All of the in-argument processin was
> overwhelming for what I needed (no in-arguments).

Cool. If you ever DO need the more complex InParameters, you should find
the RegProv example gives everything you need to know for JScript (the
superior Microsoft supplied scripting language).

You may want to check your code below though - you've put

for ( ; e.atEnd(); e.moveNext() )

this would usually read

for ( ; !e.atEnd(); e.moveNext() )

> var q = "SELECT * FROM Win32_Process";
> var e = New Enumerator( GetObject( "winmgmts:{impersonationLevel=impersonate}!//./root/cimv2" ).ExecQuery( q ) );
>
> WScript.Echo("User\tPID");
>
> for ( ; e.atEnd(); e.moveNext() )
> {
> var x = e.item();
> var ometh = x.Methods_.Item("GetOwner");
> var xout = x.ExecMethod_(ometh.Name, null);
> var user = xout.User;
> var domain = xout.Domain;
>
> WScript.Echo(user + "\t" + x.ProcessId );
> }
>
> Thanks anyhow!
>
> -R
>
>
>>Hi,
>>
>>I don't see why it's any different to the Registry Provider example?
>>What exactly is the problem? What code do you have so far?
>>
>>Swoop Fast wrote:
>>
>>
>>>I've been mucking around with the documentation on msdn.microsoft.com
>>>about how to have multiple out arguments in JScript, but the only example
>>>is with registry manipulation. I was wondering if anyone could help me
>>>out by showing me some code using Win32_Process.GetOwner() in JScript.
>>>
>>>Thanks!
>>>
>>>-R
>
>

-- 
Gerry Hickman (London UK)