Controlling services

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VBTricks.de.vu Webmaster

    #1

    Controlling services

    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.VBTric ks.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
    _______________ _______________ _______________ ________
  • Ken Tucker [MVP]

    #2
    Re: Controlling services

    Hi,

    The servicecontroll er class does what you want.

    Dim s As System.ServiceP rocess.ServiceC ontroller

    For Each s In System.ServiceP rocess.ServiceC ontroller.GetSe rvices
    If s.ServiceName = "MSSQLSERVE R" Then
    If s.Status = ServiceProcess. ServiceControll erStatus.Stoppe d
    Then s.Start()
    End If
    's.Stop to stop
    's.Start to start
    's.Pause to pause
    Next


    Ken
    --------------------
    "VBTricks.d e.vu Webmaster" <nospam@thisser verdoesntexist. com> wrote in
    message news:%23iFJb5ax FHA.904@tk2msft ngp13.phx.gbl.. .[color=blue]
    > 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.VBTric ks.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
    > _______________ _______________ _______________ ________[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Controlling services

      "VBTricks.d e.vu Webmaster" <nospam@thisser verdoesntexist. com> schrieb:[color=blue]
      > 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.[/color]

      Take a look at the 'ServiceControl ler' class.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      Working...