pier_nasos
pier_nasos

Reputation: 678

Extend the time the Windows service is stopped

I need the service to stop long enough. Approximately 5-10 minutes. Now on windows 10, my service system kills after 60 seconds without waiting for it to finish correctly. Saw a similar issue for C# using the net function RequestAdditionalTime. But I need a C++ implementation on the API.

setting the key value in the registry did not affect HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WaitToKillService set to 300000

Upvotes: 0

Views: 597

Answers (1)

Werner Henze
Werner Henze

Reputation: 16726

You should not mess with global registry settings.

When stopping your service please call SetServiceStatus with SERVICE_STOP_PENDING and set dwCheckPoint and dwWaitHint to a proper value. And according to the documentation for dwWaitHint call ServServiceStatus multiple times until you are done and the service is stopped (SetServiceStatus(h, SERVICE_STOPPED, ...)).

Upvotes: 2

Related Questions