Is there a way to increase windows service startup timeout for a specific service?

时间:2018-07-24 10:02:44

标签: c# windows-services timeout startup

I need to increase a startup timeout for one of my windows services (startup=automatic) to be able to start it after a reboot. It starts normally if I start it manually or use startup=delayed type, but I would like to keep it automatic I can increase it by changing ServicesPipeTimeout registry key, but that will increase timeout for all windows services, whereas I want to do it for only one specific service.

Another solution is to use RequestAdditionalTime in my OnStartup method I found it here windows service startup timeout, however again it does not suit me because it seems OnStart does not even run at all, probably windows needs some time to load different dlls before starting the service and 30 seconds is just not enough after a PC reboot.

Is there another way to do it maybe setting some other registry key-values to increase timeout for only one service?

1 个答案:

答案 0 :(得分:0)

You can modify the timeout value in the registry.


1. Click Start, click Run, type regedit, and then click OK.
2. Locate and then click the following registry subkey:
 - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
3. In the right pane, locate the ServicesPipeTimeout entry.

**Note**: If the ServicesPipeTimeout entry does not exist, you must create it. To do this, follow these steps:

 - On the Edit menu, point to New, and then click DWORD Value.
 - Type ServicesPipeTimeout, and then press ENTER. 
4. Right-click ServicesPipeTimeout, and then click Modify.
5. Click Decimal, type 60000, and then click OK.
 - This value represents the time in milliseconds before a service times out.
6. Restart the computer.