Solved

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

Posted on 2009-07-16
2
640 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
ID: 24871653
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
ID: 31604328
awesome thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

729 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