Check if Service is running?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joris De Groote

    #1

    Check if Service is running?

    Hi,

    can vb check if a windows service is running or not? ( Webclient )

    Thanks
    Joris


  • Herfried K. Wagner [MVP]

    #2
    Re: Check if Service is running?

    "Joris De Groote" <joris.degroote @skynet.be> schrieb:[color=blue]
    > can vb check if a windows service is running or not? ( Webclient )[/color]

    On the client or on the server? I doubt that this is possible on the client
    without writing some ugly ActiveX control or .NET Browser Control. Maybe
    it's better to develop a classic rich-client Windows Forms application
    instead of a Web application.

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

    Comment

    • Joris De Groote

      #3
      Re: Check if Service is running?

      It's a VB.NET program that runs on a server, so it's not a web application.


      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
      news:eC0LLM3cGH A.3840@TK2MSFTN GP04.phx.gbl...[color=blue]
      > "Joris De Groote" <joris.degroote @skynet.be> schrieb:[color=green]
      >> can vb check if a windows service is running or not? ( Webclient )[/color]
      >
      > On the client or on the server? I doubt that this is possible on the
      > client without writing some ugly ActiveX control or .NET Browser Control.
      > Maybe it's better to develop a classic rich-client Windows Forms
      > application instead of a Web application.
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://classicvb.org/petition/>[/color]


      Comment

      • jayeldee

        #4
        Re: Check if Service is running?

        Joris,

        If you set a reference to System.ServiceP rocess, you could use a
        function like this one below to check it. I use it in a service of
        mine to check for dependency services.

        Function CheckIfServiceI sRunning(ByVal serviceName As String) As
        Boolean

        Dim mySC As ServiceProcess. ServiceControll er
        mySC = New ServiceProcess. ServiceControll er(serviceName)
        If mySC.Status = ServiceProcess. ServiceControll erStatus.Stoppe d
        Then
        ' Service isn't running
        Return False
        ElseIf mySC.Status =
        ServiceProcess. ServiceControll erStatus.Runnin g Then
        ' Service already running
        Return True
        End If

        End Function

        Comment

        • jayeldee

          #5
          Re: Check if Service is running?

          You'd also want to put that in a Try Catch block. You'll get an
          exception if the service name is invalid IIRC.

          Comment

          • vbnetdev

            #6
            Re: Check if Service is running?

            So you are checking the server to verify this particular service is running
            right?



            --
            Get a powerful web, database, application, and email hosting with KJM
            Solutions




            "Joris De Groote" <joris.degroote @skynet.be> wrote in message
            news:eIRBOT3cGH A.5016@TK2MSFTN GP04.phx.gbl...[color=blue]
            > It's a VB.NET program that runs on a server, so it's not a web
            > application.
            >
            >
            > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
            > news:eC0LLM3cGH A.3840@TK2MSFTN GP04.phx.gbl...[color=green]
            >> "Joris De Groote" <joris.degroote @skynet.be> schrieb:[color=darkred]
            >>> can vb check if a windows service is running or not? ( Webclient )[/color]
            >>
            >> On the client or on the server? I doubt that this is possible on the
            >> client without writing some ugly ActiveX control or .NET Browser Control.
            >> Maybe it's better to develop a classic rich-client Windows Forms
            >> application instead of a Web application.
            >>
            >> --
            >> M S Herfried K. Wagner
            >> M V P <URL:http://dotnet.mvps.org/>
            >> V B <URL:http://classicvb.org/petition/>[/color]
            >
            >[/color]


            Comment

            • Joris De Groote

              #7
              Re: Check if Service is running?

              Thanks

              "jayeldee" <jayeldee@gmail .com> wrote in message
              news:1147186678 .274759.42120@e 56g2000cwe.goog legroups.com...[color=blue]
              > You'd also want to put that in a Try Catch block. You'll get an
              > exception if the service name is invalid IIRC.
              >[/color]


              Comment

              • Joris De Groote

                #8
                Re: Check if Service is running?

                Yep


                "vbnetdev" <vbnetdev@commu nity.nospam> wrote in message
                news:eZG4$C5cGH A.4148@TK2MSFTN GP05.phx.gbl...[color=blue]
                > So you are checking the server to verify this particular service is
                > running right?
                >
                >
                >
                > --
                > Get a powerful web, database, application, and email hosting with KJM
                > Solutions
                > http://www.kjmsolutions.com
                >
                >
                >
                > "Joris De Groote" <joris.degroote @skynet.be> wrote in message
                > news:eIRBOT3cGH A.5016@TK2MSFTN GP04.phx.gbl...[color=green]
                >> It's a VB.NET program that runs on a server, so it's not a web
                >> application.
                >>
                >>
                >> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                >> news:eC0LLM3cGH A.3840@TK2MSFTN GP04.phx.gbl...[color=darkred]
                >>> "Joris De Groote" <joris.degroote @skynet.be> schrieb:
                >>>> can vb check if a windows service is running or not? ( Webclient )
                >>>
                >>> On the client or on the server? I doubt that this is possible on the
                >>> client without writing some ugly ActiveX control or .NET Browser
                >>> Control. Maybe it's better to develop a classic rich-client Windows
                >>> Forms application instead of a Web application.
                >>>
                >>> --
                >>> M S Herfried K. Wagner
                >>> M V P <URL:http://dotnet.mvps.org/>
                >>> V B <URL:http://classicvb.org/petition/>[/color]
                >>
                >>[/color]
                >
                >[/color]


                Comment

                Working...