{
ManagementBaseObject inPar = null;
ManagementClass mc = new ManagementClass("Win32_Service");
foreach (ManagementObject mo in mc.GetInstances())
{
if (mo["Name"].ToString() == "服务名")
{
inPar = mo.GetMethodParameters("Change");
inPar["DesktopInteract"] = true;
mo.InvokeMethod("Change", inPar, null);
}
}
}