I am having difficulty getting the User Name of a person logged into a machine using a windows service.
When using both System.Environment.UserName or WindowsIdentity.Ge
For XP only, this advice should apply: Get Window Station for a non-interactive user per process, user or session?
OpenWindowStation
to get a handle to "winsta0"GetUserObjectInformation
to find out who owns winsta0However, this approach will break when you upgrade your app to Vista, Windows 7 or above, where services run in a different session from interactive logons. You'll need to call the terminal services API to get a list of logged on users, and pick your 'interactive' one.