Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. To Check a Window Service on C#.Net

To Check a Window Service on C#.Net

Scheduled Pinned Locked Moved C#
csharpapachemysqlcomquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    biswabhusan
    wrote on last edited by
    #1

    Hi, I want to create a start up application that will check the MYSQL SERVICE RUNNING or Not & IF it is running then it will Kill that & Exit. Else it will run an exe setup file. Any one Please suggest me how can i check WINDOW SERVICE in DotNet. & How can i kill APACHE by using command line from my programe. Thanks connect me @ panda.biswabhusan@gmail.com

    D B 2 Replies Last reply
    0
    • B biswabhusan

      Hi, I want to create a start up application that will check the MYSQL SERVICE RUNNING or Not & IF it is running then it will Kill that & Exit. Else it will run an exe setup file. Any one Please suggest me how can i check WINDOW SERVICE in DotNet. & How can i kill APACHE by using command line from my programe. Thanks connect me @ panda.biswabhusan@gmail.com

      D Offline
      D Offline
      DaGol
      wrote on last edited by
      #2

      Hi, take a look on the class ServiceController (include Reference System.ServiceProcess). Sample: ServiceController controller = new ServiceController(); controller.Refresh(); // Controller should read state if (controller.State == ServiceControllerStatus.Running) // Service is running... ... you will receive an exception if the specified service does not exist.

      B 1 Reply Last reply
      0
      • B biswabhusan

        Hi, I want to create a start up application that will check the MYSQL SERVICE RUNNING or Not & IF it is running then it will Kill that & Exit. Else it will run an exe setup file. Any one Please suggest me how can i check WINDOW SERVICE in DotNet. & How can i kill APACHE by using command line from my programe. Thanks connect me @ panda.biswabhusan@gmail.com

        B Offline
        B Offline
        biswabhusan
        wrote on last edited by
        #3

        Dim service() As System.ServiceProcess.ServiceController Dim i As Integer service = System.ServiceProcess.ServiceController.GetServices() For i = 0 To service.Length - 1 If service(i).ServiceName = "wampapache" Then If service(i).Status = ServiceControllerStatus.Running Then ' Kill the Service service(i).Stop() Application.Exit() Else Dim startInfo As System.Diagnostics.ProcessStartInfo Dim pStart As New System.Diagnostics.Process startInfo = New System.Diagnostics.ProcessStartInfo("E:\Biswabhusan_Collection\COREPRACTICE\TestService\wamp5_1.6.1.exe") pStart.StartInfo = startInfo pStart.Start() pStart.WaitForExit() 'Your code will halt until the exe file has executed. End If End If Next solveed - Biswabhusan

        1 Reply Last reply
        0
        • D DaGol

          Hi, take a look on the class ServiceController (include Reference System.ServiceProcess). Sample: ServiceController controller = new ServiceController(); controller.Refresh(); // Controller should read state if (controller.State == ServiceControllerStatus.Running) // Service is running... ... you will receive an exception if the specified service does not exist.

          B Offline
          B Offline
          biswabhusan
          wrote on last edited by
          #4

          Thank you.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups