窗口服务获得当前用户名"System". [英] Window Service GOt Current User name "System"
问题描述
嗨
我试图在窗口服务中获取当前用户名(登录用户).
like
this.name = System.Environment.UserName;
或
this.name = System.Windows.Forms.SystemInformation.UserName;
OR
this.name = WindowsIdentity.GetCurrent().Name;
然后在窗口服务中,我将其设置更改为
右键单击窗口服务
点击属性
在登录"标签中
点击本地系统帐户
选中允许服务与桌面交互"
现在我试图获取我的用户名,然后给出"System"作为用户名.
那是因为该服务在系统"帐户,但不在登录的用户帐户下.
hi
I am tried to get current user name(Loged in user) in my window service.
like
this.name = System.Environment.UserName;
Or
this.name = System.Windows.Forms.SystemInformation.UserName;
OR
this.name = WindowsIdentity.GetCurrent().Name;
then in window service I changed its setting like
right click in window service
click property
in Log On tab
click Local System Account
check Allow service to interact with desktop
Now I tried to get my user name then It give "System" as user name. so how to get current user name when above settings in window services is done?
That is because the service is running under "system" account but not under the logged-on user account.
这篇关于窗口服务获得当前用户名"System".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!