本文介绍了窗口服务获得当前用户名"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?

解决方案


这篇关于窗口服务获得当前用户名"System".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:07