是否可以使用 devon.exe 按名称删除 USB 大容量存储设备?以下代码用于删除所有设备:
Devcon remove usbstor\*
但现在我想删除一个特定的设备。例如,如果插入 5 个 USB,则 A
、B
、C
、D
、E
和 F
,我现在只想删除 B
。我知道实例 ID 用于此目的,但是否可以使用设备名称删除?例如,像
Devcon remove usbstor\B
我试过了,但没用。
最佳答案
您可以通过硬件 ID 删除单个设备。如果您知道该 id,则可以使用删除命令,否则您将必须找出硬件 id。有关详细信息,请参阅帮助:
Devcon Remove Command
Removes devices with the specified hardware or instance ID. Valid only on
the local computer. (To reboot when necesary, Include -r .)
Devcon.exe [-r] remove <id> [<id>...]
Devcon.exe [-r] remove =<class> [<id>...]
<class> Specifies a device setup class.
Examples of <id>:
* - All devices
ISAPNP\PNP0501 - Hardware ID
*PNP* - Hardware ID with wildcards (* matches anything)
@ISAPNP\*\* - Instance ID with wildcards (@ prefixes instance ID)
'*PNP0501 - Hardware ID with apostrophe (' prefixes literal match - matches exactly as typed,
including the asterisk.)
关于c# - 使用 devcon.exe 删除 USB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10534983/