1
Answer

Finding the process "Username"

Kasun Lee

Kasun Lee

2y
1k
1

Hi.


After I get a process using C#, how can i go about finding the "Username" ("SYSTEM" / [user] etc) of that process, as listed in taskmanager?

foreach (Process proc in procs){// proc.(?)}


Or at least the originator of the process -- the System or one of the Users.

 

Thanks.

EDIT: I tried to run my code only if the username is not "SYSTEM" using StartInfo.UserName, but that gives me the exception "Process was not started by this object, so requested information cannot be determined."..


if (proc.StartInfo.UserName != "SYSTEM") // Exception
{
}

Any work-around for that plz?

Answers (1)