Loop though services

  • Thread starter Thread starter Mike Walters
  • Start date Start date
M

Mike Walters

I am trying to loop thought all the services on a system and stat/stop
then as needed, I know How I can start or stop then, but how do I loop
thought all installed services.

Thanks
Mike
 
(e-mail address removed) (Mike Walters) wrote in
I am trying to loop thought all the services on a system and stat/stop
then as needed, I know How I can start or stop then, but how do I loop
thought all installed services.


I use WMI to loop through the services as well as start and stop.
 
Hi,


Dim s As System.ServiceProcess.ServiceController

For Each s In System.ServiceProcess.ServiceController.GetServices

Dim strOut As String = String.Format("{0} {1} {2}", s.ServiceName, s.Status,
s.ServiceType)

Trace.WriteLine(strOut)

's.Stop to stop

's.Start to start

's.Pause to pause

Next





Ken

----------------------

I am trying to loop thought all the services on a system and stat/stop
then as needed, I know How I can start or stop then, but how do I loop
thought all installed services.

Thanks
Mike
 

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

Back
Top