Power off an USB device in software on Windows

前端 未结 5 1722
轮回少年
轮回少年 2020-11-27 17:00

I would like to power cycle an USB device through software on Windows.

I am doing development on a small USB power microcontroller. This chip will revert to native b

5条回答
  •  旧时难觅i
    2020-11-27 17:38

    There is a simple solution to this on Windows if you buy this external USB hub. It has an undocumented feature that cycles power to all connected USB devices whenever the hub is "enabled" in Windows Device Manager. You can do this manually:

    1. Run "Device Manager"
    2. Expand "Universal Serial Bus controllers"
    3. Open Properties for the appropriate "Generic USB Hub"
    4. Select the "Driver" tab
    5. Click the "Disable" button
    6. Click the "Enable" button. The hub will briefly disable power output to all 4 of its USB ports, and then enable it again.

    You can also do this programmatically from any Windows application that is running with administrator priveledges. Here is an example in C#.

    I have successfully used this technique to cycle power to USB devices that were "locked up". It sure beats physically unplugging devices, especially on remote or unmanned PCs.

提交回复
热议问题