I am using the following code to change the credentials of a windows service. Before I display the message that credentials were successfully changed, I want to confirm the new credentials have been applied. How can I do that?
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");
}