473,753 Members | 6,232 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 #1
12 14535
Hello tshad,

If you are not the author of service you definitely can't know running it
or not, because for example web-Methods Server services start really running
after 20 mins as service set "running" status.

The only way to check whether it run is to check that files/environment that
service control

tWhat would be a good way to check programmaticall y whether a service
twas running?
t>
tWe have a service that dies periodically and I need to check to see
tif this service is running. I know how to check to see if the status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
t>
tI need to know this so that if it happens I can programmaticall y
tstart the same service on another machine.
t>
tWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
t>
tThanks,
t>
tTom
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 9 '06 #2
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:9c******** *************** ***@msnews.micr osoft.com...
Hello tshad,

If you are not the author of service you definitely can't know running it
or not, because for example web-Methods Server services start really
running after 20 mins as service set "running" status.
I am the author of the service.

But I have a service that sends out emails that shows in running mode and
for some reason it dies once every 5 or 6 days and seems to be frozen (could
be in an infinite loop - but I can't find where that would happen). The
status in the services windows or when I request it from another program
shows it as running (which would make sense if it never hit the Stop code.

I need to find a good way to monitor it to tell if it has stopped or not
(until I can find the problem with the code).

BTW, when I get to this point, I can't stop the program at all. I need to
reboot the server to get it released.
>
The only way to check whether it run is to check that files/environment
that service control
Not sure what you mean here.

Thanks,

Tom
tWhat would be a good way to check programmaticall y whether a service
twas running?
ttWe have a service that dies periodically and I need to check to see
tif this service is running. I know how to check to see if the status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
ttI need to know this so that if it happens I can programmaticall y
tstart the same service on another machine.
ttWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
ttThanks,
ttTom
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 9 '06 #3
Hello tshad,

I'm not sure that such brutal way to fix you service is a good way :)

Why not to make some internal check, for example whether email was send or
not or for example each day in midnight restart service.

t"Michael Nemtsev" <ne*****@msn.co mwrote in message
tnews:9c******* *************** ****@msnews.mic rosoft.com...
t>
>Hello tshad,

If you are not the author of service you definitely can't know
running it or not, because for example web-Methods Server services
start really running after 20 mins as service set "running" status.
tI am the author of the service.
t>
tBut I have a service that sends out emails that shows in running mode
tand for some reason it dies once every 5 or 6 days and seems to be
tfrozen (could be in an infinite loop - but I can't find where that
twould happen). The status in the services windows or when I request
tit from another program shows it as running (which would make sense
tif it never hit the Stop code.
t>
tI need to find a good way to monitor it to tell if it has stopped or
tnot (until I can find the problem with the code).
t>
tBTW, when I get to this point, I can't stop the program at all. I
tneed to reboot the server to get it released.
t>
>The only way to check whether it run is to check that
files/environment that service control
tNot sure what you mean here.
t>
tThanks,
t>
tTom
t>
>tWhat would be a good way to check programmaticall y whether a
service
twas running?
ttWe have a service that dies periodically and I need to check to
see
tif this service is running. I know how to check to see if the
status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
ttI need to know this so that if it happens I can
programmatical ly
tstart the same service on another machine.
ttWhat I would like to do is build a service that just
periodically
tchecks (about once a minute) to see if the other service is
actually
trunning.
ttThanks,
ttTom
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
---
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 9 '06 #4
On way would be to have teh service right to a db table every now and
then, and have another service that monitors that table.

Although trying to figure out why the service dies would be a better
solution.

andy

tshad wrote:
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:9c******** *************** ***@msnews.micr osoft.com...
Hello tshad,

If you are not the author of service you definitely can't know running it
or not, because for example web-Methods Server services start really
running after 20 mins as service set "running" status.

I am the author of the service.

But I have a service that sends out emails that shows in running mode and
for some reason it dies once every 5 or 6 days and seems to be frozen (could
be in an infinite loop - but I can't find where that would happen). The
status in the services windows or when I request it from another program
shows it as running (which would make sense if it never hit the Stop code.

I need to find a good way to monitor it to tell if it has stopped or not
(until I can find the problem with the code).

BTW, when I get to this point, I can't stop the program at all. I need to
reboot the server to get it released.

The only way to check whether it run is to check that files/environment
that service control

Not sure what you mean here.

Thanks,

Tom
tWhat would be a good way to check programmaticall y whether a service
twas running?
ttWe have a service that dies periodically and I need to check to see
tif this service is running. I know how to check to see if the status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
ttI need to know this so that if it happens I can programmaticall y
tstart the same service on another machine.
ttWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
ttThanks,
ttTom
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 9 '06 #5
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:9c******** *************** ***@msnews.micr osoft.com...
Hello tshad,

I'm not sure that such brutal way to fix you service is a good way :)
This is more of a bandaid until I figure out what the problem is.

Part of the problem may be that the program was originally written in VS
2002 and I heard there was some problem with services it built. I did
rebuild it in 2003 and it seems to work better, but I can't be sure yet.

I also am writing trace statements to a text file at various points in the
program to try an figure out what it does just before it dies (or appears to
die).
Why not to make some internal check, for example whether email was send or
not or for example each day in midnight restart service.
The first would be doable, but the 2nd wouldn't help. We can't wait for
possibly 12 hours for the reboot to take place as the emails wouldn't be
sent out in time.

The other problem would be how to start the same service on another server
if we determine that the program quits working (checking the email records
to see if they were sent as you suggest, for example). Not sure how to do
that yet.

Thanks,

Tom
>
t"Michael Nemtsev" <ne*****@msn.co mwrote in message
tnews:9c******* *************** ****@msnews.mic rosoft.com...
t>
>>Hello tshad,

If you are not the author of service you definitely can't know
running it or not, because for example web-Methods Server services
start really running after 20 mins as service set "running" status.
tI am the author of the service.
ttBut I have a service that sends out emails that shows in running
mode
tand for some reason it dies once every 5 or 6 days and seems to be
tfrozen (could be in an infinite loop - but I can't find where that
twould happen). The status in the services windows or when I request
tit from another program shows it as running (which would make sense
tif it never hit the Stop code.
ttI need to find a good way to monitor it to tell if it has stopped or
tnot (until I can find the problem with the code).
ttBTW, when I get to this point, I can't stop the program at all. I
tneed to reboot the server to get it released.
t>
>>The only way to check whether it run is to check that
files/environment that service control
tNot sure what you mean here.
ttThanks,
ttTom
t>
>>tWhat would be a good way to check programmaticall y whether a
service
twas running?
ttWe have a service that dies periodically and I need to check to
see
tif this service is running. I know how to check to see if the
status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
ttI need to know this so that if it happens I can
programmatica lly
tstart the same service on another machine.
ttWhat I would like to do is build a service that just
periodicall y
tchecks (about once a minute) to see if the other service is
actually
trunning.
ttThanks,
ttTom
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
---
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 9 '06 #6
"Andy" <aj*****@alum.r it.eduwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
On way would be to have teh service right to a db table every now and
then, and have another service that monitors that table.
That is what I may do in the mean time.
Although trying to figure out why the service dies would be a better
solution.
Am working on that now, but need a band aid at the moment.

Thanks,

Tom
>
andy

tshad wrote:
>"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:9c******* *************** ****@msnews.mic rosoft.com...
Hello tshad,

If you are not the author of service you definitely can't know running
it
or not, because for example web-Methods Server services start really
running after 20 mins as service set "running" status.

I am the author of the service.

But I have a service that sends out emails that shows in running mode and
for some reason it dies once every 5 or 6 days and seems to be frozen
(could
be in an infinite loop - but I can't find where that would happen). The
status in the services windows or when I request it from another program
shows it as running (which would make sense if it never hit the Stop
code.

I need to find a good way to monitor it to tell if it has stopped or not
(until I can find the problem with the code).

BTW, when I get to this point, I can't stop the program at all. I need
to
reboot the server to get it released.
>
The only way to check whether it run is to check that files/environment
that service control

Not sure what you mean here.

Thanks,

Tom
tWhat would be a good way to check programmaticall y whether a service
twas running?
ttWe have a service that dies periodically and I need to check to
see
tif this service is running. I know how to check to see if the
status
tis in stopped or running mode. But that doesn't tell me if it is
tactually running.
ttI need to know this so that if it happens I can programmaticall y
tstart the same service on another machine.
ttWhat I would like to do is build a service that just periodically
tchecks (about once a minute) to see if the other service is actually
trunning.
ttThanks,
ttTom
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 9 '06 #7
There's a ServiceControll er class, I'm pretty sure its in .Net 1.1 too.

Andy

tshad wrote:
"Andy" <aj*****@alum.r it.eduwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
On way would be to have teh service right to a db table every now and
then, and have another service that monitors that table.
That is what I may do in the mean time.
Although trying to figure out why the service dies would be a better
solution.

Am working on that now, but need a band aid at the moment.

Thanks,

Tom
Aug 10 '06 #8
"Andy" <aj*****@alum.r it.eduwrote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
There's a ServiceControll er class, I'm pretty sure its in .Net 1.1 too.
That was what I was looking for.

Thanks,

Tom
>
Andy

tshad wrote:
>"Andy" <aj*****@alum.r it.eduwrote in message
news:11******* *************** @b28g2000cwb.go oglegroups.com. ..
On way would be to have teh service right to a db table every now and
then, and have another service that monitors that table.
That is what I may do in the mean time.
Although trying to figure out why the service dies would be a better
solution.

Am working on that now, but need a band aid at the moment.

Thanks,

Tom

Aug 10 '06 #9
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

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 #10

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
6896
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
25658
by: Joris De Groote | last post by:
Hi, can vb check if a windows service is running or not? ( Webclient ) Thanks Joris
4
4180
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
12839
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
9072
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
8896
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
9653
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9421
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
9333
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
8328
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
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2872
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2284
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.