user1387147
user1387147

Reputation: 955

Remove USB using devcon.exe

Is it possible to remove a USB mass storage device by name using devon.exe? The following code is used to remove all devices:

Devcon remove usbstor\*

but now I want to remove a particular device. For example, if 5 USBs are plugged in, A, B, C, D, E and F, I now want to remove only B. I know that instance id is used for this purpose but is it possible to remove using the device name? For example, like

Devcon remove usbstor\B

I tried this but it doesn't work.

Upvotes: 2

Views: 3053

Answers (1)

Peter Ritchie
Peter Ritchie

Reputation: 35881

You can remove an individual device by hardware ID. If you know the id, you can use the remove command, otherwise you'll have to find out the hardware id. For more information see the help:

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.)

Upvotes: 2

Related Questions