有没有办法增加特定服务的windows服务启动超时



我需要增加一个windows服务的启动超时(启动=自动(,以便在重新启动后能够启动它。如果我手动启动或使用startup=delayed类型,它会正常启动,但我希望保持automatic我可以通过更改ServicesPipeTimeout注册表项来增加超时时间,但这将增加所有windows服务的超时时间,而我只想为一个特定的服务增加超时时间。

另一个解决方案是在我的OnStartup方法中使用RequestAdditionalTime,我在这里找到了它windows服务启动超时,然而,它再次不适合我,因为OnStart似乎根本没有运行,可能windows在启动服务之前需要一些时间加载不同的dll,而在PC重新启动后30秒是不够的。

有没有其他方法可以做到这一点,比如设置一些其他注册表项值,只增加一个服务的超时时间?

您可以在注册表中修改超时值。


1. Click Start, click Run, type regedit, and then click OK.
2. Locate and then click the following registry subkey:
- HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControl
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.

最新更新