No announcement yet.

NT Service on system shutdown

  • Filter
  • Time
  • Show
Clear All
new posts

  • NT Service on system shutdown


    Is there an equivalent to %SERVICE_STOP_PENDING for the
    %SERVICE_CONTROL_SHUTDOWN NT service control? Maybe something like
    %SERVICE_SHUTDOWN_PENDING? I'm trying to clean things up nicely
    in this service I'm writing when the OS shuts down and my
    service is still running. I'm getting through my %SERVICE_CONTROL_SHUTDOWN
    logic in my service handler, but the service automatically
    shuts down after about 20-21 seconds, even though it could
    take me up to 60 seconds to clean things up. I've tested this
    by looping for 60 seconds within this logic before continuuing
    but it still shuts down after 20 seconds. I've also tried setting
    the dwWaitHint value to 60 seconds.


    Scott Wolfington

    [This message has been edited by Scott Wolfington (edited March 05, 2003).]
    Scott Wolfington

  • #2
    From win32 helpfile:
    When the user shuts down the system, all control handlers receive the
    SERVICE_CONTROL_SHUTDOWN control code. They are notified in the order that
    they appear in the database of installed services. By default, a service
    has approximately 20 seconds to perform cleanup tasks before the system
    shuts down. However, if the system is left in the shutdown state (not restarted
    or powered down) the service continues to run.
    You can change the time the system will wait for service shutdown by modifying
    the WaitToKillServiceTimeout value in the following registry key:


    mailto[email protected][email protected]</A>

    "Simplicity is a prerequisite for reliability"


    • #3
      Hi Peter,

      I saw that WaitToKillServiceTimeout reg setting too. I really
      want to refrain from making any registry changes though. Maybe
      I should just try to come up with a way to insure that my service has
      done everything it needs to do within that 20 second shutdown
      window. On most occassions (95-97% of the time) the service will
      be done wrapping things up within that 20 seconds. I'm still
      open to ideas though.


      Scott Wolfington

      [This message has been edited by Scott Wolfington (edited March 05, 2003).]
      Scott Wolfington