Power off USB port programmatically

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

However, it looks like they only have on / off buttons. They cannot interact with the software.

So I was thinking if I could find a way to turn off the power of the USB port, that would allow me to turn the lights on and off using my app. However, I cannot find a way to power off the USB port. Is it possible?

+3


source to share


3 answers


If you have administrator rights, follow these steps:



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

      

0


source


Flash-off-2 power is fed through a regular USB plug, which means they are 5 volts and there is one and one motor in each.

I couldn't find how many ampere requirements are required, but I know this expansion would be ideal if 200mA is enough for one energy efficient flashlight.

USB controller expansion

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 www.Nusbio.net and I think the extension is in their store. I used a similar extension nusbio.

turn on / off my USB fan and battery powered lamp

+1


source


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

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

  • Go to Device Manager and find out which USB controller you should enable / disable so that your device no longer receives power. For me, turning off the "USB to serial converter" turns off the power to all USB slots.

USB to Serial Converter in Device Manager

  1. In C #, create and start a new disconnect device process (using the USB controller name).

    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 turn it back on.

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

0


source







All Articles