get the username associated with a process

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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>
 
Back
Top