Q:

How to disable/enable a specific USB port in windows with python?

I want to create a toggle switch in graphical window that can Disable/Enable specific USB port in windows with python, which external command or library can I use?

A:

Use devcon.exe:
import subprocess
# Fetches the list of all usb devices:
result = subprocess.run(['devcon', 'hwids', '=usb'], 
    capture_output=True, text=True)

# ... add code to parse the result and get the hwid of the device you want ...

subprocess.run(['devcon', 'disable', parsed_hwid]) # to disable
subprocess.run(['devcon', 'enable', parsed_hwid]) # to enable

