1
我正在使用以下代碼更改Windows服務的憑據。在顯示證書已成功更改的消息之前,我想確認已應用新證書。我怎樣才能做到這一點?確認服務憑據已更改
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");
}
+1 - 這是一個更自然的API用於此目的。 – 2010-10-27 15:24:13