使用ServiceController更改服务凭据

有没有办法做到这一点,而不是使用当前不在我的环境中使用WMI,使用ServiceController类。

using (ManagementObject service = new ManagementObject(new ManagementPath(objPath))) { object[] wmiParams = new object[11]; wmiParams[6] = _username; wmiParams[7] = _password; service.InvokeMethod("Change", wmiParams); Thread.Sleep(2000); //check if new credentials in order //Console.WriteLine("Service credentials changed"); } 

谢谢!

Solutions Collecting From Web of "使用ServiceController更改服务凭据"