handling services from C#

S

SR

Hi all I am able to get the list of services from C#
using System.ServiceProcess.ServiceController ->
GetServices() method. However, I don't find any C# method
that will change the StartMode of any service. I
currently know of changing the StartMode programmatically
by going to
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AnySe
rviceName key. Is there any other recommended way? Please
let me know. Thanks for all your help.
 
N

Nicholas Paldino [.NET/C# MVP]

SR,

I would use the WMI Win32_Service class for this. Once you have that,
you can make a call to the ChangeStartMode method on that class to set the
start mode.

Hope this helps.
 
G

Guest

How Could I get Services From other Machines on same Domain using
Win32_Service?

Nicholas Paldino said:
SR,

I would use the WMI Win32_Service class for this. Once you have that,
you can make a call to the ChangeStartMode method on that class to set the
start mode.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

SR said:
Hi all I am able to get the list of services from C#
using System.ServiceProcess.ServiceController ->
GetServices() method. However, I don't find any C# method
that will change the StartMode of any service. I
currently know of changing the StartMode programmatically
by going to
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AnySe
rviceName key. Is there any other recommended way? Please
let me know. Thanks for all your help.
 

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