Solved

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

Posted on 2009-07-16
2
635 Views
Last Modified: 2012-05-07
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
Comment
Question by:sbornstein2
2 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:sbornstein2
Comment Utility
awesome thanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now