1

I am trying to get a DomainName\UserName associated with a Process in a C# application. All the other data I need to collect about a application I can access via the Process.GetProcessesById() method. The object returned also contains a property for the DomainName and UserName however this always seems to be an empty string when getting an existing process.

I know I can also get this information by querying the WMI object for the user name, however is there anyway to get this by simply doing the following?

Process.GetProcessById(1234).StartInfo.UserName
Ali
  • 3,373
  • 5
  • 42
  • 54
Lightning77
  • 313
  • 5
  • 14
  • I'm not sure I understand the question. To paraphrase "Using option A doesn't work. Using option B does work. But is there some magical way to make option A work despite the fact that I already know it doesn't work?" (i.e. if there is a way to make option A work, it's not going to "simply" be to use option A) – Damien_The_Unbeliever Jul 19 '17 at 18:41
  • I guess I'm just wondering if there is something I need to do to get it to populate this data, or why is it always blank? So I can avoid using the latter if possible. – Lightning77 Jul 19 '17 at 18:44
  • Related: accepted _Mark Benningfield_'s answer to [Retrieving username of a running process](https://social.msdn.microsoft.com/Forums/vstudio/en-US/aeff7e41-a4ba-4bf0-8677-81162040984d/retrieving-username-of-a-running-process?forum=netfxbcl). – JosefZ Jul 19 '17 at 20:16

0 Answers0