简体   繁体   中英

Disable USB device on Python in Windows 10

I have an RFID reader that works as a Keyboard, so, if I click on a Text Entry and put a card near the reader, it puts the content read on the text entry. The latest RFID reader I was using works via serial connection, so I can open and close the connection to avoid fake positives, but with this new model, I can't do that, so I need to disable and enable the device without unplug it from the USB, just like if I do from the Windows Device Manager.

I have tried with pyusb but, in Windows, it doesn't display nothing, (I have tried the same on my RPi 3 and it works properly, but I don't know if I could disable the port).

By the way, I also tried with infi.devicemanager but this only list all peripherals connected and doesn't let me disable/enable it.

Is there any way to do this, like edit the registry, or acess it via cmd prompt.

Thanks!

There is command line tool for this called DevCon . You can disable devices using devcon-disable command. It's supported by Microsoft and since it's a command line tool you can use it programmatically. Here is an example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM