I have simplest possible windows service.
I need service to run under Local System account.
If I start/stop service from SCM, everything works f
Microsoft Windows has added an option called Fast Startup
which does not actually shutdown the computer.
As noted in the Fast Startup
setting description, Restart
isn't affected. This is why the Restart
triggers OnShutdown
and Shutdown
does not.
Turning off Fast Startup
will trigger OnShutdown
for both Restart
and Shutdown
.
From what I researched, the OnShutdown method is called when the OS is shutdown, but there is there is a strict time limit, but i believe the local system services are terminated even before this time limit so that OS shutdown time is fast. This might explain why domain account are shutdown slower. Windows has introduced a PreShutdown event to handle this. Try the link below, it has more information on this https://www.atomia.com/2011/11/16/how-to-process-the-preshutdown-event-in-a-managed-windows-service/