简体   繁体   中英

Turn off power to USB Port programmatically

I have a project that I'm working on and I want to use these: http://www.woot.com/blog/post/usb-powered-woot-off-lights-2

However it looks like they just have on/off switches. They aren't something that you can interface with programmatically.

So I was thinking, if I could find a way to cut the power to the USB port, that would allow me to turn the lights on and off with my app. However I cant find any way to cut the power to the USB port. Is this possible?

I had a similar problem and solved it using DevManView.exe (freeware):

  1. Download DevManView.exe and put the .exe file somewhere: http://www.nirsoft.net/utils/device_manager_view.html

  2. Go to your Device Manager and figure out which USB-Controller you have to enable/disable, so that your device does/doesn't get power anymore. For me disabling "USB Serial Converter" does cut the power of all USB slots.

USB Serial Converter in device manager

  1. In C#, create and start a new process for disabling the device (using the name of the USB-Controller).

     Process devManViewProc = new Process(); devManViewProc.StartInfo.FileName = @"<path to DevManView.exe>\\DevManView.exe"; devManViewProc.StartInfo.Arguments = "/disable \\"USB Serial Converter\\""; devManViewProc.Start(); devManViewProc.WaitForExit();
  2. And enable it again.

     devManViewProc.StartInfo.Arguments = "/enable \\"USB Serial Converter\\""; devManViewProc.Start(); devManViewProc.WaitForExit();

EDIT: unfortunately it seems the products from this company are not sold anymore .


The powered-woot-off-lights-2 are powered via a regular usb plug which mean they are 5 volts and there are in each one light and one motor.

I could not find how many Amps are needs but I know that this extension would be perfect if 200 mA for one powered-woot-off-lights is enough.

USB Controler Extension

The C# or VB.NET code would look like this.

// On
nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(true);
nusbio.GPIOS[NusbioGpio.Gpio1].DigitalWrite(true);
// Off
nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(false);
nusbio.GPIOS[NusbioGpio.Gpio1].DigitalWrite(false);

see Nusbio's website and I think the extension is in their store. I used a similar nusbio extension myself.

to turn on/off my a USB fan and a battery powered small lamp

如果您有管理员权限,请运行以下命令:

Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord); 

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