Search code examples
c#c++windowsservicetimeout

What's the time-out value for the start-up of a Windows service


In order to debug a Windows service, written here in my company, the main function starts with:

Sleep(3000); // three seconds

This should allow me to do an "Attach to Process" while the service is starting up, but I seem to be too slow, so I decided to modify this value to 30,000 (thirty seconds).

However now, when starting up the service, I get following error message:

Prompt>net start <Service_Application>
The service is not responding to the control function.

What is the maximum value I can put there in order not to fall into such time-out?


Solution

  • You can get the value by accessing the registry key at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control key ServicesPipeTimeout .

    If this value is not set, its default value is set to 30 s ( see https://learn.microsoft.com/en-us/windows/win32/services/service-control-handler-function to learn more about it ).