如何使用c#配置设备安装超时

How to configure device installation time-out using c#

Windows 设备安装的默认超时时间为 5 分钟,这对于速度较慢的计算机或连接了很多设备的计算机来说是不够的。我发现有一个计算机策略可以配置这个超时值。

1. Click Start > Run, type gpedit.msc, and click OK.
2. In the left pane, go to Computer Configuration > Administrative Templates > System > Device Installation.
3. In the right pane, click Configure device installation time-out and click Policy Setting.
4. In the popup that appears, select the Enabled option.
5. Increase the value of Device Installation Time (in seconds) option. For example, set it to 1800 (30 minutes).
6. Click Apply and then click OK. 

Reference

但是,这涉及到用户交互,我想找到一种编程方式来配置它,最好是在 C# 中。有什么想法吗?

谢谢。

您可以从 Group Policy Settings Reference for Windows and Windows Server.

中获取此类信息(存储在 Windows 注册表中)

从这里您可以获得存储 Configure device installation time-out 的注册表项。

HKLM\Software\Policies\Microsoft\Windows\DeviceInstall\Settings!InstallTimeout 

从这一点来看,使用 .Net Registry Class 修改此类值非常简单。