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:
Comments
Post a Comment