The
DevCon[^] example in the
WDK[^] is a command-line utility that shows how to enable, disable, restart, update, remove and query devices using the SetupAPI and CfgMgr32 API functions.
Download
DevCon from here:
devcon.exe[
^]
Learn using
DevCom from the command-line:
devcon help
Find hardware IDs for all USB devices:
devcon find "USB\*"
Restart your desired HUB or any other device:
devcon restart "USB\ROOT_HUB20\5&3849BCE7&0"
If power limits on your USB port have been exceeded use
devcon rescan
to reset it, or do something of everything from your C# console application:
using System;
using System.Diagnostics;
namespace Test
{
class Program
{
public static void Main(string[] args)
{
var p = new Process();
p.StartInfo = new ProcessStartInfo( @"devcon.exe", @"find USB\*" );
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Hope this helps!
Tefik Becirovic