5

How can I toggle the power to a USB port on/off using batch or the command line? I am using Windows 8 to do this. Does anyone know what I could do? I have 4 USB ports.

6
+50

You would need external hardware, such as a USB controlled relay. Windows itself does not provide a API or option to allow the power pins of USB ports to be switched off. This has been answered previously here and summarized history here.

| improve this answer | |
  • This doesn't use batch or command line. – 09stephenb Feb 22 '14 at 16:12
  • Depending on the means of control, it could. Still, it's not possible as is. USB ports cannot be switch off. There's simply no such facility. – Daniel B Feb 22 '14 at 16:14
4

Analysis of the problem

Since Vista, USB devices remain powered-on even after they are safely removed.

The Microsoft article USB Port Remains Active for Disabled or Safely Removed USB Device describes this new behavior :

In Windows XP and Windows Server 2003, when a USB device is marked as Removed, the USB hub port to which it is connected is Disabled. When the port is Disabled, no further USB traffic is sent to the device.

In Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2, when a USB device is marked as Removed, the USB hub port to which it is connected is not Disabled.

I believe this behavior is what you are trying to change, in order to power-down devices that you have removed.

Solution

Power-down cannot be done via a batch script, but it can be returned to its XP behavior by modifying the registry, either as global setting for all USB devices or per-device.

To apply the workaround globally for all enumerated USB devices,
add a REG_DWORD value named DisableOnSoftRemove that has a value of 1 to the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbhub\HubG.

To apply the workaround for a specific device,
add a REG_DWORD value named DisableOnSoftRemove that has a value of 1 to the following registry subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\usbflags\vvvvpppprrrr
where vvvv is the device's Vendor ID, pppp is the device's Product ID, and rrrr is the device's Revision number (found in Device Manager).

| improve this answer | |
2

There is a powershell module that you can use to e.g. disable devices.

With this you could stop the operating system from using the USB ports. But this doesn't kill the power supply to these ports. Because that is in general not possible without modifying the hardware.

Only shutting down the computer might cut the power. Some computers have sleep-and-charge ports. Those provide power even if the computer is switched off (as long as there is a mains connection or a battery with sufficient charge available).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.