get the username associated with a process

G

Guest

Hi,

I am trying to get the name of the user which stared a process... similar to
the user name column in the process list in task manager. I have looked
through the Process members but am at a loss to find what I require!

Any help would be greatly appreciated.
 
P

Patrick Steele [MVP]

Hi,

I am trying to get the name of the user which stared a process... similar to
the user name column in the process list in task manager. I have looked
through the Process members but am at a loss to find what I require!

Any help would be greatly appreciated.

You'll have to do some PInvoke with the Win32 API. Here's a C# example
that shows the calls and process:

http://tinyurl.com/dtvva
 
H

Herfried K. Wagner [MVP]

Director - Minvent said:
I am trying to get the name of the user which stared a process... similar
to
the user name column in the process list in task manager. I have looked
through the Process members but am at a loss to find what I require!

You can utilize the 'Win32_Process' class and its 'GetOwner' method to
determine domain and user the process is belonging to. The documentation on
'Win32_Process' contains a VBScript sample on how to do that:

Platform SDK: Windows Management Instrumentation -- 'Win32_Process'
<URL:http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp>

Samples for VB.NET and C# can be found here:

<URL:http://www.google.to/groups?q=dotnet+Win32_Process+GetOwner+-herfried>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top