473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Checking if a service is up

r
Hi,
I would like to check from within my c# app,
if certain services are up or down, to activate and to stop
them.
Any idea on how to do it?
Thanks in advance

Nov 17 '05 #1
2 1189
Hello,
You can manipulate existing windows services using ServiceController
class in System.ServiceProcess namespace. You can create the service
controller with the following line of code:

System.ServiceProcess.ServiceController controller = new
System.ServiceProcess.ServiceController("ServiceNa meGoesHere");

you can check about the service state through
System.ServiceProcess.ServiceControllerStatus.

if(controller.Status ==
System.ServiceProcess.ServiceControllerStatus.Runn ing)
controller.Stop();

Please see MSDN for further details on Manipulating Windows services.

HTH. Cheers.
Maqsood Ahmed [MCP C#,SQL Server]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
You can also use WMI for this. Check out System.Management namespace.

"r" <ra****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,
I would like to check from within my c# app,
if certain services are up or down, to activate and to stop
them.
Any idea on how to do it?
Thanks in advance

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: SKBergam | last post by:
Hi. I am writing a service as well as a monitor program that I can use to start and stop the service plus monitor it's performance. I am wondering if there is a way that I can have an event in my...
3
by: Steven Blair | last post by:
Hi, Is it posssible to check if the SQL service is running. I have some code accessing a SQL Database, but I get a nasty message if I forget to start SQL Service. -- Steven...
3
by: Ann Marinas | last post by:
Hi, All! I just would like to ask... Is it possible that you can detect whether a Windows Service is existing or not? If this is possible, how can you implement it? Thank you! A
4
by: Simon Verona | last post by:
My software relies on a third party data provider to a propretary database. In turn the third party database relies on a Windows Service that runs on the server to supply the data... The problem...
2
by: Dariusz Tomon | last post by:
Hi I embedded in HTML code checking my form before sending it: I get the following error: What is the way to do JS checking on the form with runat="server"? Regards Darek T
3
by: salman | last post by:
hello i want to start/install any service or demean with my software (during installation or running software) for future updates. how can i do this? can i include any thread or process to...
8
by: Josetta | last post by:
Hopefully, I can explain what I want to do and hopefully, one of you can point me in the right direction. Here goes: I have a table with a bunch of companies (hundreds). They all perform...
1
by: mengesb | last post by:
I'm looking to utilize something to the effect of this code: ps -ef | grep sc_serv | grep -v grep | awk '{print $2}' > sc_serv.pid cat sc_serv.pid 3447 3449 The first id it spits out is the...
1
by: =?Utf-8?B?QVZM?= | last post by:
hi, i need to check the availability of my web service.... how can i do that. i dont want to call any of the methods present in web service to test availability.. i just want to ping to the web...
3
by: John Wright | last post by:
I need to know how to check the state of a windows service. I need to determine if the windows service "Smart Card" is running. If it is not running, I need to start the service. Also it would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.