How to disable and enable USB port via command prompt? Or using a batch script or VBScript? The OS is Windows 7.
Asked
Active
Viewed 3.7k times
6
-
what do you mean by disable? As in turn it of physically? – Piotr Kula Nov 07 '12 at 10:04
-
no. problematically disable the usb port to prevent unauthorized access data from my pc – open source guy Nov 07 '12 at 10:08
1 Answers
13
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"
mvp
- 4,320
- 21
- 27
-
Can it also disable the USB port for devices that draw power from the USB port? For e.g. USB lamps etc? – bluelurker Nov 28 '20 at 22:50
-
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](https://github.com/mvp/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. – mvp Nov 28 '20 at 23:45
-