Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 649
  • Last Modified:

ASP.Net/C# - how to check if service is started or not in code

I need to check in my C# code in my web app if a windows service is started or not and then show an image for start and stop based on that.  Any idea what syntax I can use to check if it is started based on a service name?
0
sbornstein2
Asked:
sbornstein2
1 Solution
 
jinalCommented:
I hope you have all neccessary permission for that.

use ServiceControl class for that.

For that you have to add System.ServiceProcess assembly refrence.
http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller.aspx

System.ServiceProcess.ServiceController controller = new System.ServiceProcess.ServiceController("name of the service")
            controller.Status.ToString();

Open in new window

0
 
sbornstein2Author Commented:
awesome thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now