Given a service name, I would like to retrieve the username that it runs under (i.e. the username shown in the \'Log On\' tab of a service\'s properties window). There doesn
Try this:
System.Security.Principal.WindowsIdentity.GetCurrent();
but the most obvious you will get LOCAL SYSTEM or NETWORK. The reason that you cannot show this user - that service can manage multiple users (shared by desktop, attached to current windows session, using shared resource ...) System starts service, but any user can use it.