windows service Logon credentials change

G

Guest

Hi All,

we have four app servers and 5 services are installed in each machine.
For every 60 days we need to change winodws domain users passwords, which
the services run.

Is there any way we can grab the service programatically and change service
logon credentials using C# utility?
I can loop through all services installed on the machine using the following
code.

foreach(ServiceController sc1 in ServiceController.GetServices())
{
MessageBox.Show(sc1.DisplayName.ToString());


}

But I don't know how to change service logon credentials.
Do you guys have any idea?
Thanks
Anil
 
W

Willy Denoyette [MVP]

Anil said:
Hi All,

we have four app servers and 5 services are installed in each machine.
For every 60 days we need to change winodws domain users passwords, which
the services run.

Is there any way we can grab the service programatically and change
service
logon credentials using C# utility?
I can loop through all services installed on the machine using the
following
code.

foreach(ServiceController sc1 in ServiceController.GetServices())
{
MessageBox.Show(sc1.DisplayName.ToString());


}

But I don't know how to change service logon credentials.
Do you guys have any idea?
Thanks
Anil

Why not simply use the command line utility 'sc.exe' provided by the system
for this?

This command:
sc \\serverX config SomeService password= xxxx

changes the password of the service SomeService on serverX

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top