How to find the username that a process is running under
-
I need to be able to determine what user name a process is running under. I can get the process object by using... Process[] p = Process.GetProcessByName("theprocess"); But I need to know if the process is running under the same user name as the account that the current user is logged in under. I know I can get the user name with Environment.Username, but I need to get the process' user name like Task Manager does. Can anyone help?
Darryl Borden Principal IT Analyst dborden@eprod.com
-
I need to be able to determine what user name a process is running under. I can get the process object by using... Process[] p = Process.GetProcessByName("theprocess"); But I need to know if the process is running under the same user name as the account that the current user is logged in under. I know I can get the user name with Environment.Username, but I need to get the process' user name like Task Manager does. Can anyone help?
Darryl Borden Principal IT Analyst dborden@eprod.com
Hello
Process[] p = Process.GetProcessByName("theprocess");
MessageBox.Show(p.StartInfo.Username);Regards
-
Hello
Process[] p = Process.GetProcessByName("theprocess");
MessageBox.Show(p.StartInfo.Username);Regards
I found a previous reference to that, but the StartInfo object that comes up in my IDE does not have a "Username" property.
Darryl Borden Principal IT Analyst dborden@eprod.com
-
I found a previous reference to that, but the StartInfo object that comes up in my IDE does not have a "Username" property.
Darryl Borden Principal IT Analyst dborden@eprod.com
Hello ProcessStartInfo.Usename property is available in .net framework 2.0 or later. Probably you're using version 1.1 or 1.0. Upgrade to .Net 2.0 by buying Visual Studio 2005, downloading Visual C# express edition, or downloading .Net 2.0 SDK and using its libraries explicitly. Regards:rose:
-
I need to be able to determine what user name a process is running under. I can get the process object by using... Process[] p = Process.GetProcessByName("theprocess"); But I need to know if the process is running under the same user name as the account that the current user is logged in under. I know I can get the user name with Environment.Username, but I need to get the process' user name like Task Manager does. Can anyone help?
Darryl Borden Principal IT Analyst dborden@eprod.com
-
Use WMI or Windows Management Instrumentation. Build a Management Object on the process under discussion. Call its InvokeMethod() and pass "GetOwner" as the method parameter. This way, you can find the owner of a process.
Best, Jun
Thank you - this solution worked great for me. I sincerely appreciate your willingness to answer my question.
Darryl Borden Principal IT Analyst dborden@eprod.com
-
Thank you - this solution worked great for me. I sincerely appreciate your willingness to answer my question.
Darryl Borden Principal IT Analyst dborden@eprod.com