Windows services shutdown order

  • Thread starter Thread starter Bill Sonia
  • Start date Start date
B

Bill Sonia

I'm written a Windows Service to send e-mails on events
like OnStart, OnStop, OnShutDown using System.Web.Mail.
It works for everything but OnShutdown. My guess is that
once my send mail code is executed, other necessary
Windows Services have been terminated before it can
actually send the mail. I've updated my
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
registry DependOnService value including SMPTSVC and
others. My hope is that the services will shut-down in
reverse order from start-up; I haven't had any luck with
this.

My Questions:
Do Windows Services (Windows 2000) shutdown in the reverse
order from which they start-up?

If so, any idea's as to which service I should include as
a dependency?

If not, is there anyway I can ensure my Windows Service is
the first to shutdown?

Thanks,

~Bill
 
Good article but it's a little lower level then my
original question. I have a windows service that will
send e-mail discribing the status of my server. I'm
trying to send an e-mail on shutdown but thus far have
been unsuccessful. Is there a way I can trigger this
before all of the appropriate services are shutdown? Do
the services shutdown in reverse order from which they
started?

Thanks
 
Hi Bill,

If these services have dependency relationship, they should be shutdown in
reverse order of start; if not, they can be shutdown seperately. I suggest
you take a look at this article:

Debugging Windows Service Applications
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbtskdebuggingserviceapplications.asp

You may debug into the lines in shutdown event to see if you find any
further information.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
If I understand your question correctly, your service fails to send email
because the email service is no longer active, or SMTP service actually, if
thats the case maybe you want to put the SMTP service in your list of
Services that your service depends on so you can send mail until the point
your service shutsdown.

Ray
 
Back
Top