473,769 Members | 5,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check if a Windows service running

What would be a good way to check programmaticall y whether a service was
running?

We have a service that dies periodically and I need to check to see if this
service is running. I know how to check to see if the status is in stopped
or running mode. But that doesn't tell me if it is actually running.

I need to know this so that if it happens I can programmaticall y start the
same service on another machine.

What I would like to do is build a service that just periodically checks
(about once a minute) to see if the other service is actually running.

Thanks,

Tom
Aug 9 '06
12 14536
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:9c******** *************** ***@msnews.micr osoft.com...
Hello tshad,

Take into account that in some cases this isn't the solution, even if the
service status is in running status it may be hunged or smth
I agree.

I can do as was suggested about checking the DB to see if my emails were
sent. Since I know when the email records were written to the file, I can
do a check every 5 minutes or so to see if there are any email 5 minutes
and if so, stop the service (even if it is hung - shouldn't hurt), then
start the service on a different service and send and email that this
process happened so we can restart the machine.

It would be nice to restart the machine remotely also (not sure how to do
that yet).

Thanks,

Tom
>
t"Andy" <aj*****@alum.r it.eduwrote in message
tnews:11******* *************** @i42g2000cwa.go oglegroups.com. ..
t>
>>There's a ServiceControll er class, I'm pretty sure its in .Net 1.1
too.
tThat was what I was looking for.
t>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche


Aug 10 '06 #11
WMI and System.Manageme nt is what you need to look at.
See your other thread for a reply.

Willy.
"tshad" <ts**********@f tsolutions.comw rote in message
news:OA******** *****@TK2MSFTNG P06.phx.gbl...
| "Michael Nemtsev" <ne*****@msn.co mwrote in message
| news:9c******** *************** ***@msnews.micr osoft.com...
| Hello tshad,
| >
| Take into account that in some cases this isn't the solution, even if
the
| service status is in running status it may be hunged or smth
|
| I agree.
|
| I can do as was suggested about checking the DB to see if my emails were
| sent. Since I know when the email records were written to the file, I can
| do a check every 5 minutes or so to see if there are any email 5 minutes
| and if so, stop the service (even if it is hung - shouldn't hurt), then
| start the service on a different service and send and email that this
| process happened so we can restart the machine.
|
| It would be nice to restart the machine remotely also (not sure how to do
| that yet).
|
| Thanks,
|
| Tom
|
| >
| t"Andy" <aj*****@alum.r it.eduwrote in message
| tnews:11******* *************** @i42g2000cwa.go oglegroups.com. ..
| t>
| >>There's a ServiceControll er class, I'm pretty sure its in .Net 1.1
| >>too.
| >>>
| tThat was what I was looking for.
| t>
| ---
| WBR,
| Michael Nemtsev :: blog: http://spaces.msn.com/laflour
| >
| "At times one remains faithful to a cause only because its opponents do
| not cease to be insipid." (c) Friedrich Nietzsche
| >
| >
|
|
Aug 11 '06 #12
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:OH******** ********@TK2MSF TNGP06.phx.gbl. ..
WMI and System.Manageme nt is what you need to look at.
See your other thread for a reply.
Looking at that now.

Thanks,

Tom
>
Willy.
"tshad" <ts**********@f tsolutions.comw rote in message
news:OA******** *****@TK2MSFTNG P06.phx.gbl...
| "Michael Nemtsev" <ne*****@msn.co mwrote in message
| news:9c******** *************** ***@msnews.micr osoft.com...
| Hello tshad,
| >
| Take into account that in some cases this isn't the solution, even if
the
| service status is in running status it may be hunged or smth
|
| I agree.
|
| I can do as was suggested about checking the DB to see if my emails were
| sent. Since I know when the email records were written to the file, I
can
| do a check every 5 minutes or so to see if there are any email 5
minutes
| and if so, stop the service (even if it is hung - shouldn't hurt), then
| start the service on a different service and send and email that this
| process happened so we can restart the machine.
|
| It would be nice to restart the machine remotely also (not sure how to
do
| that yet).
|
| Thanks,
|
| Tom
|
| >
| t"Andy" <aj*****@alum.r it.eduwrote in message
| tnews:11******* *************** @i42g2000cwa.go oglegroups.com. ..
| t>
| >>There's a ServiceControll er class, I'm pretty sure its in .Net 1.1
| >>too.
| >>>
| tThat was what I was looking for.
| t>
| ---
| WBR,
| Michael Nemtsev :: blog: http://spaces.msn.com/laflour
| >
| "At times one remains faithful to a cause only because its opponents
do
| not cease to be insipid." (c) Friedrich Nietzsche
| >
| >
|
|


Aug 11 '06 #13

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

Similar topics

3
2217
by: Brad Jones | last post by:
Hello, I'm hoping someone can give me some help or guidance here. I'm not sure if this is even the best group to post to for this. Our OEM equipment's software architecture relies heavily on a "master" windows service. This responsibility of this service is to launch 10 or so other applications, some of which have GUI's. These applications need to be running whether somebody is logged in or not. There is no communication required between...
7
712
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: service 1 - my service watches service 2 - windows service service 2 is stopped - service 1 starts service 2
2
5932
by: Chris Podmore | last post by:
I don't know if this is the correct newsgroup but I couldn't find one for Windows Services Is it possible to check that a Windows Service is still running from another machine The idea being a couple of machines will be running my Windows Services to handle certain parts of our application, these machines will be located in the server room. I would like to create an application that runs on one of the users PC's that checks that these...
3
3690
by: Doug Bailey | last post by:
I am trying to control a Windows Service via a Web Service interface. (I am developing in .NET2003) I am using the ServiceController object which allows me to read the state of the services with no problems. However, I am not able to start or stop the service unless I go through the process of impersonating an administrative user. (See MSDN KB 306158) Since it appears to be a privilege issue, I set the folders in IIS holding the Web...
5
1911
by: Tony | last post by:
Every 10 seconds I need to search a SQL table for orders to print. The orders are created through WebForms on ASP.NET clients. The orders should not print until 10 minutes before they are due. The network printer will be available from the server running IIS and SQL Server 2000. If this were a Windows Forms application, then I would create a system timer in Form1.Load(). How is this done in an ASP.NET application?
2
6898
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app (which is the UI used to adjust the actions taken by, and the schedule of the service), then a privileged user thread should be used in the UI - no service required. But... "A windows service enables the creation of long-running executable
7
25661
by: Joris De Groote | last post by:
Hi, can vb check if a windows service is running or not? ( Webclient ) Thanks Joris
4
4182
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to check to see if the status is in stopped or running mode. But that doesn't tell me if it is actually running. I need to know this so that if it happens I can programmatically start the same service on another machine.
12
12846
by: Shadlan | last post by:
Hi. I need to know if a service is running on my server. Is there any PHP instruction that I can use to do this?
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9849
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8861
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.