Controlling services

  • Thread starter VBTricks.de.vu Webmaster
  • Start date
V

VBTricks.de.vu Webmaster

Hello,

I'm trying to speed up windows start a bit. Therefore I want to start
some services at a later point of time and some only if I run the
application which needs the services.
The first point is no problem, "net start" allows manual start of a
service. The tricky one is the second. Is there any .net class that
allows controling the services? I need to check if a specific service
(identified by name) is running and to start it, if it is not running.


Thanks in advance,

Stefan

--
___________________________________www.VBTricks.de.vu
the free resource for Visual Basic, Gambas and Pascal
components, tips & complete projects

www: http://www.VBTricks.de.vu
mail: vbtricks <at> gmx <dot> net
_____________________________________________________
 
K

Ken Tucker [MVP]

Hi,

The servicecontroller class does what you want.

Dim s As System.ServiceProcess.ServiceController

For Each s In System.ServiceProcess.ServiceController.GetServices
If s.ServiceName = "MSSQLSERVER" Then
If s.Status = ServiceProcess.ServiceControllerStatus.Stopped
Then s.Start()
End If
's.Stop to stop
's.Start to start
's.Pause to pause
Next


Ken
 
H

Herfried K. Wagner [MVP]

VBTricks.de.vu Webmaster said:
The first point is no problem, "net start" allows manual start of a
service. The tricky one is the second. Is there any .net class that
allows controling the services? I need to check if a specific service
(identified by name) is running and to start it, if it is not running.

Take a look at the 'ServiceController' class.
 

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