1

Regular service written in Delphi XE7 (windows 10 22H2). In OnStart Event I create some objects, I read inifile etc. StartType = stAuto. Windows service set up: automatically.

When my service state is:

  • running during system shutdown (by shut down system option) it starts at system startup but without calling services' OnStart Event. Just like resumed from the point it stopped working.
  • running during system shutdown (by restart system option) it starts at system startup but with OnStart Event called.
  • stopped at both previous conditions it does not start at all.

Is it normal behaviour or I'm missing somethig?

4
  • I have used TService for decades and never had the OnStart event not fire. It doesn't matter how the service is started. Are you sure you actually did a full system shutdown and not just a standby/hibernation? Commented Feb 19 at 15:57
  • 2
    If you are running this on Windows 10 or newer this is the default behaviour. Why? Microsoft decided that in order to allow computer to boot up faster the default shutdown command causes windows to go into state similar to hibernation. While users programs are completely shutdown due the fact that user is logged out, the system services still remain and their state is then stored similar as it would during hibernation. You can even observe this by looking at System up-time information in windows Task Manager. Commented Feb 19 at 20:55
  • @SilverWarior that should be posted as an answer. Commented Feb 19 at 22:38
  • I forgot to mention that even if service is set to start manually (in windows service manager) it starts automatically after system was started/rebooted if before shut down service was runing. Commented Feb 20 at 7:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.