C# – Turn off power to USB Port programmatically

cc#-4.0net

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?

Best Answer

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();
    
Related Topic