There's really no pressing reason for me to ask this question other than curiosity - using C#, is there a way to determine from within code which user my process is running as? To illustrate using code:
static void Main(string[] args) { string userID; //what goes here to fill in this userID variable? Console.out.WriteLine(string.Format("This process is running as {0}.", userID)); }
string userID = WindowsIdentity.GetCurrent().Name
From MSDN: WindowsIdentity.GetCurrent() and WindowsIdentity.Name
string UserID = Environment.UserName;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With