c# - Change service credentials using ServiceController -


is there way this, instead of using wmi not working in environment, using servicecontroller class.

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");                 } 

thanks!

the servicecontroller class doesn't let change service credentials. if wmi isn't option, can p/invoke changeserviceconfig instead. can find c# example here:

changing log on credentials of windows services


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -