Get User Name
-
Is there a way i can get the user name associated with the processes just like in task manager.
Well, in VB 2005, this single line of code works :
This returns the Name of the User under which the current process is running Yuvi Panda T Microsoft Student Partner Blogs at : http://yuvipanda.blogspot.com
-
Well, in VB 2005, this single line of code works :
This returns the Name of the User under which the current process is running Yuvi Panda T Microsoft Student Partner Blogs at : http://yuvipanda.blogspot.com
-
Do you mean get current username logged in PC? If so :
using System.Security.Partial; . . . .
string username = System.WindowsIdentity.GetCurrent().Name.Tostring();
it gives DomainName\Username -
Not sure, but I guess this should help:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
Yuvi Panda T 15 Year Old Microsoft Student Partner Blogs at : http://yuvipanda.blogspot.com
-
Not sure, but I guess this should help:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
Yuvi Panda T 15 Year Old Microsoft Student Partner Blogs at : http://yuvipanda.blogspot.com
-
check this article http://www.eggheadcafe.com/articles/20011015.asp
-
Not sure, but I guess this should help:
System.Security.Principal.WindowsIdentity.GetCurrent().Name
Yuvi Panda T 15 Year Old Microsoft Student Partner Blogs at : http://yuvipanda.blogspot.com
-
Is there a way i can get the user name associated with the processes just like in task manager.
if you're working on a win 2k, xp or 2k3 machine, check into the system.management namespace. it allows you to connect to wmi which has the information you need.
-jim
-
Is there a way i can get the user name associated with the processes just like in task manager.
The Process class doesn't expose this functionality. The best method, like Jim said, would be to use WMI and the Win32_Process[^] class. Once you get the list of Win32_Process objects, call the GetOwner method on each one to get the information you need. Dave Kreskowiak Microsoft MVP - Visual Basic
-
The code snippet that was posted will give you the name of the user running the process. It is usually but not always the person who is logged in. Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]
-
The Process class doesn't expose this functionality. The best method, like Jim said, would be to use WMI and the Win32_Process[^] class. Once you get the list of Win32_Process objects, call the GetOwner method on each one to get the information you need. Dave Kreskowiak Microsoft MVP - Visual Basic