Solved

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

Posted on 2009-07-16
2
638 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…

749 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