首页 > 解决方案 > 有没有办法增加特定服务的 Windows 服务启动超时?

问题描述

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

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

是否有另一种方法可以设置其他一些注册表键值来增加仅一个服务的超时?

标签: c#windows-servicestimeoutstartup

解决方案


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


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.


推荐阅读