首页 > 系统 > Windows > 正文

windows中允许服务与桌面交互的更改 方法

2019-11-02 14:52:15
字体:
来源:转载
供稿:网友

 这篇文章主要介绍了windows中允许服务与桌面交互的更改方法,需要的朋友可以参考下

在Windows服务的安装类ProjectInstaller中加入以下方法:  代码如下:protected override void OnCommitted(System.Collections.IDictionary savedState){base.OnCommitted(savedState);//将服务更改为允许桌面交互模式ConnectionOptions coOptions = new ConnectionOptions();coOptions.Impersonation = ImpersonationLevel.Impersonate;ManagementScope mgmtScope = new System.Management.ManagementScope(@"rootCIMV2", coOptions);mgmtScope.Connect();ManagementObject wmiService;wmiService = new ManagementObject("Win32_Service.Name='这里是当前服务名'"
野兔影院[www.aikan.tv/special/yetuyingyuan/]
;);ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");InParam["DesktopInteract"] = true;ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam, null);}  
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表