protected
override void OnComm
ITted(
System.Collections.IDictionary save
dstate)
{
base.OnCommitted(saved
state);
//将服务更
改为允许桌面交互模式
ConnectionOptions coOptions = new ConnectionOptions();
coOptions.Im
PErsonation = ImpersonationLevel.Impersonate;
ManagementScope mgmtScope = new System.Management.ManagementScope(@"root\CIMV2", coOptions);
mgmtScope.Connect();
ManagementObject wmiService;
wmiService = new ManagementObject("Win32_Service.N
ame='这里是当前服务名'");
ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");
InParam["DesktopInteract"] = true;
ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam, null);
}