PnPUtil (PnPUtil.exe) 包含在从 Windows Vista 开始的每个版本的 Windows 中,位于 %windir%\system32 目录中。
若要运行 PnPUtil,请打开命令提示符窗口, (以管理员身份运行) 并使用以下语法和参数键入命令。
PNPUTIL [/add-driver <...> | /delete-driver <...> |
/export-driver <...> | /enum-drivers |
/enum-devices [<...>] | /enum-devicetree [<...>] |
/disable-device <...> | /enable-device <...> |
/restart-device <...> | /remove-device <...> |
/scan-devices [<...>] | /enum-classes [<...>] |
/enum-interfaces [<...>] | /enum-containers [<...>] |
/?]
命令
/add-driver
将驱动程序包 () 添加到驱动程序存储中。 从 Windows 10 版本 1607 开始提供命令。
PNPUTIL /add-driver <filename.inf | *.inf> [/subdirs] [/install] [/reboot]
从 Windows 10 版本 1607 开始可用的标志:
-
/subdirs- 遍历驱动程序包的子目录 -
/install- 在任何匹配的设备上安装/更新驱动程序 -
/reboot- 如果需要完成操作,请重新启动系统
注意
如果驱动程序不是系统上排名最高的驱动程序,PnPUtil 不会强制其安装到设备上。
若要检查匹配驱动程序及其排名,请在提升的命令提示符下运行以下命令:pnputil /enum-devices /instanceid <devgen device instance ID ROOT\DEVGEN{...}> /drivers。
/delete-driver
从驱动程序存储中删除驱动程序包。 从 Windows 10 版本 1607 开始提供命令。
PNPUTIL /delete-driver <oem#.inf> [/uninstall] [/force] [/reboot]
从 Windows 10 版本 1607 开始可用的标志:
-
/uninstall- 从使用它的任何设备卸载驱动程序包 -
/force- 删除驱动程序包,即使设备正在使用它 -
/reboot- 如果需要完成操作,请重新启动系统
/export-driver
将驱动程序包 () 从驱动程序存储导出到目标目录。 从 Windows 10 版本 1607 开始提供命令。
PNPUTIL /export-driver <oem#.inf | *> <target directory>
/enum-drivers
枚举驱动程序存储中的所有第三方驱动程序包。 从 Windows 10 版本 1607 开始提供命令。
PNPUTIL /enum-drivers [/class <name | GUID>] [/files]
从 Windows 11 版本 21H2 开始可用的标志:
-
/class <name | GUID>- 按驱动程序类名或 GUID 进行筛选
从 Windows 11 版本 22H2 开始可用的标志:
-
/files- 枚举所有驱动程序包文件
/disable-device
禁用系统上的设备。 从 Windows 10 版本 2004 开始提供命令。
PNPUTIL /disable-device [<instance ID> | /deviceid <device ID>]
[/class <name | GUID>]
[/bus <name | GUID>]
[/reboot] [/force]
从 Windows 10 版本 2004 开始可用的标志:
-
/reboot- 如果需要完成操作,请重新启动系统
从 Windows 11 版本 21H2 开始可用的标志:
-
/deviceid <device ID>- 禁用具有匹配设备 ID 的所有设备
从 Windows 11 版本 22H2 开始可用的标志:
-
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/bus <name | GUID>- 按总线枚举器名称或总线类型 GUID 进行筛选 -
/force- 即使设备提供关键系统功能,也禁用
/enable-device
在系统上启用设备。 从 Windows 10 版本 2004 开始提供命令。
PNPUTIL /enable-device [<instance ID> | /deviceid <device ID>]
[/class <name | GUID>] [/bus <name | GUID>]
[/reboot]
从 Windows 10 版本 2004 开始可用的标志:
-
/reboot- 如果需要完成操作,请重新启动系统
从 Windows 11 版本 21H2 开始可用的标志:
-
/deviceid <device ID>- 启用具有匹配设备 ID 的所有设备
从 Windows 11 版本 22H2 开始可用的标志:
-
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/bus <name | GUID>- 按总线枚举器名称或总线类型 GUID 进行筛选
/restart-device
重启系统上的设备。 从 Windows 10 版本 2004 开始提供命令。
PNPUTIL /restart-device [<instance ID> | /deviceid <device ID>]
[/class <name | GUID>] [/bus <name | GUID>]
[/reboot]
从 Windows 10 版本 2004 开始可用的标志:
-
/reboot- 如果需要完成操作,请重新启动系统
从 Windows 11 版本 21H2 开始可用的标志:
-
/deviceid <device ID>- 重启具有匹配设备 ID 的所有设备
从 Windows 11 版本 22H2 开始可用的标志:
-
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/bus <name | GUID>- 按总线枚举器名称或总线类型 GUID 进行筛选。
/remove-device
尝试从系统中删除设备。 从 Windows 10 版本 2004 开始提供命令。
PNPUTIL /remove-device [<instance ID> | /deviceid <device ID>]
[/class <name | GUID>] [/bus <name | GUID>]
[/subtree] [/reboot] [/force]
从 Windows 10 版本 2004 开始可用的标志:
-
/subtree- 删除整个设备子树,包括任何子设备 -
/reboot- 如果需要完成操作,请重新启动系统
从 Windows 11 版本 21H2 开始可用的标志:
-
/deviceid <device ID>- 删除具有匹配设备 ID 的所有设备
从 Windows 11 版本 22H2 开始可用的标志:
-
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/bus <name | GUID>- 按总线枚举器名称或总线类型 GUID 进行筛选 -
/force- 即使设备提供关键系统功能,也会删除
/scan-devices
扫描系统是否有任何设备硬件更改。 从 Windows 10 版本 2004 开始提供命令。
/scan-devices [/instanceid <instance ID>] [/async]
从 Windows 10 版本 2004 开始可用的标志:
-
/instanceid <instance ID>- 扫描设备子树中的更改 -
/async- 异步扫描更改
/enum-devices
枚举系统上的所有设备。 从 Windows 10 版本 1903 开始提供命令。
PNPUTIL /enum-devices [/connected | /disconnected]
[/instanceid <instance ID> | /deviceid <device ID>]
[/class <name | GUID>] [/problem [<code>]]
[/bus [<name | GUID>]] [/deviceids] [/relations]
[/services] [/stack] [/drivers] [/interfaces]
[/properties] [/resources]
从 Windows 10 版本 1903 开始可用的标志:
-
/connected- 按连接的设备进行筛选 -
/disconnected- 按断开连接的设备进行筛选 -
/instanceid <instance ID>- 按设备实例 ID 进行筛选 -
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/problem [<code>]- 按有问题的设备进行筛选或按特定问题代码进行筛选 -
/relations- 显示父设备与子设备关系
从 Windows 10 版本 2004 开始可用的标志:
-
/drivers- 显示匹配和已安装的驱动程序
从 Windows 11 版本 21H2 开始可用的标志:
-
/bus [<name | GUID>]- 显示总线枚举器名称和总线类型 GUID,或按总线枚举器名称或总线类型 GUID 进行筛选 -
/deviceids- 显示硬件和兼容 ID -
/services- 显示设备服务 -
/stack- 显示有效的设备堆栈信息 -
/interfaces- 显示设备接口 -
/properties- 显示所有设备属性
从 Windows 11 版本 22H2 开始可用的标志:
-
/deviceid <device ID>- 按设备硬件和兼容 ID 进行筛选 -
/resources- 显示设备资源
/enum-devicetree
枚举设备树。
命令从 Windows 11 版本 23H2 开始可用。
/enum-devicetree [root device instance ID] [/connected] [/services]
[/stack] [/drivers] [/interfaces]
root device instance ID - 从指定的根设备实例 ID 开始显示设备树。
Flags
-
/connected- 按连接的设备进行筛选 -
/services- 显示设备服务 -
/stack- 显示有效的设备堆栈信息 -
/drivers- 显示匹配和已安装的驱动程序 -
/interfaces- 显示设备接口
/enum-interfaces
枚举系统上的所有设备接口。
命令从 Windows 10 版本 1903 开始可用。
PNPUTIL /enum-interfaces [/enabled | /disabled] [/class <GUID>] [/properties]
从 Windows 10 版本 1903 开始可用的标志:
-
/enabled- 按已启用的接口进行筛选 -
/disabled- 按禁用的接口进行筛选 -
/class <GUID>- 按接口类 GUID 进行筛选
从 Windows 11 版本 22H2 开始可用的标志:
-
/properties- 显示所有接口属性
/enum-classes
枚举系统上的所有设备类。
命令从 Windows 11 版本 22H2 开始可用。
PNPUTIL /enum-classes [/class <name | GUID>] [/services]
从 Windows 11 版本 22H2 开始可用的标志:
-
/class <name | GUID>- 按设备类名称或 GUID 进行筛选 -
/services- 显示设备类服务
/enum-containers
枚举系统上的所有设备容器。
命令从 Windows 11 版本 23H2 开始可用。
PNPUTIL /enum-containers [/containerid <container id>] [/connected | /disconnected]
[/problem] [/devices] [/format <txt | xml | csv>]
[/output-file [<filename>]]
Flags
/containerid <container id> - 按容器 ID 进行筛选。
/connected | /disconnected - 按连接的设备容器进行筛选或按断开连接的设备容器进行筛选
/problem - 按有问题的设备容器进行筛选
/devices - 显示容器设备
/format - 将输出格式设置为文本、XML 或 CSV
/output-file [<filename>] - 将输出写入可选文件名
/?
显示命令行语法。
PNPUTIL /?
旧命令映射
以下命令仍受支持,但是旧版命令。 建议改用最新的语法。
-a [-i] <filename.inf> ==> /add-driver <filename.inf> [/install]
-d [-f] <oem#.inf> ==> /delete-driver <oem#.inf> [/force]
-e ==> /enum-drivers
示例
有关如何使用 PnPUtil 工具的示例,请参阅 PnPUtil 示例。