Maybe it is a bit late but I think it is possible using WMI through GetOwner() method of the Win32_Process class which retrieves the user name and domain (Below code is not mine, I have extracted it from http://social.msdn.microsoft.com/Forums/en-US/d842c407-18f5-478b-8c4f-7e14ac4fbbe6/get-owner-of-curently-runing-procesess ):
using System;
using System.Diagnostics;
using System.Management; // Add reference to System.Management!!
class Program {
static void Main(string[] args) {
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_Process");
foreach (ManagementObject queryObj in searcher.Get()) {
ManagementBaseObject outParams =
queryObj.InvokeMethod("GetOwner", null, null);
Console.WriteLine("{0} owned by {1}\\{2}", queryObj["Name"],
outParams["Domain"], outParams["User"]);
}
Console.ReadLine();
}
}
Also If you are interested in you can do it with vbscript using below code to determine the account name under which a process is running (see below page for more detailed info http://msdn.microsoft.com/en-us/library/aa394599(v=vs.85).aspx ):
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner( _
strNameOfUser,strUserDomain)
Wscript.Echo "Process " & objProcess.Name _
& " is owned by " _
& strUserDomain & "\" & strNameOfUser & "."
Next
Hope it helps!