We have systems that connect through devices that are connected to PCs through USB. In some cases there is an adapter in between so it is a RS-232 to USB conversion. Is it possible to tell the Device Manager to remove a port and then add it back in? I would like to do this so the drivers for the various devices (which in some cases are more than 1 such as the device through the USB Serial adapter) all reset. It seems removing the port and then adding it back in would ensure all the drivers reconnect. This is important as some third party drivers can get "stuck" and due to threading it is not possible to use it anymore. This means it would require a physical removal of the connection, or a full system reset.
So I am hoping someone knows if there is a simple way to connect to the device manager find Ports remove them and then reconnect them. Something like this:
public class DeviceManagerWrapper
{
public void ResetAllPorts()
{
using(var deviceManager = new System....DeviceManager()
{
foreach(var port in deviceManager.GetPorts())
{
port.Disconnect();
port.Reconnect();
}
}
}
}
Obviously this doesn't work. Just hoping for someone to point me in the right direction.