how to get logged in user and machine name from window service in c#?
问题 How to get the logged in user (interactive user) and machine name from window service in c#. When i try Environment and other class to get logged in user name it just returns NT AUTHORITY\SYSTEM from window service. 回答1: The service executes under the SYSTEM account, so that what you see in the Environment class. The machine name should not be a problem (see Gmoliv's comment). Services execute independently from whoever may be logged on: that's one of the main reasons to have them. If you