I have a Windows service which needs the currently logged username. I tried System.Environment.UserName, Windows identity and Windows form authentication, but all are returning "System" as the user my service is running as has system privileges. Is there a way to get the currently logged in username without changing my service account type?
I have a Windows service which needs the currently logged username. I tried System.Environment.UserName
Share
This is a WMI query to get the user name:
You will need to add
System.Managementunder References manually.