How to find what user is running a process

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

The Process class gives a lot of information. One piece it doesn't seem
to give you though is what user a process is running under (unless I'm
missing something here.) Does anyone have an idea on how to retrieve
this information (by the API perhaps?) I've been trying to google for
an answer, but haven't had any luck.

Thanks,
Jeff
 
Jeff,

Jeff said:
The Process class gives a lot of information. One piece it doesn't seem
to give you though is what user a process is running under (unless I'm
missing something here.) Does anyone have an idea on how to retrieve this
information (by the API perhaps?)

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

Back
Top