How to disable and enable a USB port via command prompt?

32,835

Download utility devcon from Microsoft.

Then, use it as follows: List all known USB devices:

devcon find USB*

Disable USB device:

devcon disable "USB\VID_xxxx&PID_yyyy"

Enable USB device:

devcon enable "USB\VID_xxxx&PID_yyyy"
Share:
32,835

Related videos on Youtube

open source guy
Author by

open source guy

Updated on September 18, 2022

Comments

  • open source guy
    open source guy over 1 year

    How to disable and enable USB port via command prompt? Or using a batch script or VBScript? The OS is Windows 7.

    • Piotr Kula
      Piotr Kula over 11 years
      what do you mean by disable? As in turn it of physically?
    • open source guy
      open source guy over 11 years
      no. problematically disable the usb port to prevent unauthorized access data from my pc
  • bluelurker
    bluelurker over 3 years
    Can it also disable the USB port for devices that draw power from the USB port? For e.g. USB lamps etc?
  • mvp
    mvp over 3 years
    This really depends on how Windows does it, and on hub hardware, but I don't think it is very likely. You might want to look at my utility uhubctl, however it will not work on Windows due to Microsoft decision to restrict direct access to USB hub in winusb.sys kernel driver. uhubctl will work on any other OS (Linux, Mac, *BSD, etc) provided you have compliant USB hardware - check uhubctl page for supported devices.
  • bluelurker
    bluelurker over 3 years
    thank you.. I'll take a look at uhubctl