有没有办法做到这一点,但不是使用目前在我的环境中不起作用的 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");
}
谢谢!