Windows Service Status

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In searching this site, i have seen plenty of posts and answers detailing how
to check the status of a service.

Many services, however, will "hang". Their status says that are running,
but in reality the service is non-responsive.

In light of this, I am using the ExecuteCommand method of the specified
servicecontroller to "ping" teh service. In that method I pass it a command
(an arbitrary number higher than 245). My understanding is that Services
will ignore commands that they don't recognize. Such as:

If ServiceName.Status = ServicecontrollerStatus.running then
ServiceName.Executecommand(248)
end if

My thinking is that if the service is "hung" or nonresponsive, it will error
out and fall into my Try-Catch which tells me it is hung, otherwise it will
just ignore the command and continue.

Is my thinking correct in this?

Scott
 
If you do what you indicate and the service is not 'geared-up' to handle
that command you will get an InvalidOperationException, as is stated in the
documentation for the ServiceController.ExecuteCommand method.

A 'well behaved' service will, when it fails internally, write appropriate
messages to the EventLog and take itself down cleanly.

As you have noticed, not all services are 'well-behaved'. Unfortunately
there isn't much you can do about this other than go to the supplier of the
service, thump the table and demand that they 'play the game'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top