Use the System.Management classes with the WMI Win32_Service class to change
service properties.
Check the Platform SDK -Windows Management Instrumentation for details.
Here's a sample...
public static int ChangeService(string Name, string Password, string
serviceName)
{
ManagementBaseObject inParams = null;
ManagementObject srvc = new ManagementObject("Win32_Service=" + "\"" +
serviceName + "\"");
inParams = srvc.GetMethodParameters("Change");
inParams["StartName"] = Name; //account name .\\localaccount;
domain\\domainaccount (or account@somedomain on XP and up)
inParams["StartPassword"] = Password; // password
ManagementBaseObject outParams = srvc.InvokeMethod("Change", inParams,
null);
return System.Convert.ToInt32(outParams.Properties["ReturnValue"].Value);
}
}
Willy.
"Camel Software" <Ca***************@hotmail.com> wrote in message
news:eY*************@TK2MSFTNGP12.phx.gbl...
I'd like to write a C# program that can change the login for a service
that's already installed. I'm wondering if there is an API to use for
that.
I'm familiar with ServiceController, but I don't see a way to use it.
Is it possible?
If so, how should I approach it?
Thanks,
Steve Harclerode