2

I'm working on troubleshooting a device that only works once it has been unplugged and plugged back into its USB port on the PC.

The application that talks to the device is written in C#. So I need a programmatic way in C# or perhaps batch files, etc. to reset a USB device.

Thus far I've tried using the devcon.exe tool, but that doesn't seem to do the same job that physically removing and adding it back does.

Is it possible to use Win32_USBController to control a USB device's power through the port somehow? MSDN Link

Perhaps in a similar fashion, I found the CIM_Controller class, which has Reset() function. MSDN Link

The tools for resetting a USB port in the Windows Driver Framework/Kit don't appear to be readily accessible via a library or otherwise without first creating an actual driver unless I'm mistaken.

Thanks

The Whether Man
  • 362
  • 5
  • 21

1 Answers1

-2

I would recommend that you navigate to the directory and find the device. Right click on it and in the short cut menu click on eject. The application and the OS should handle the device. It is a bad idea to "unplug" a USB device, especially flash drives without ejecting them. You could end up with open file errors.

If the problem is not ejecting the device then the issue is probably with the application. If the application is opening a file on the device and the device has to be unplugged in order to function properly then the application may not be closing the open file properly...

Just saying

You might look at the SO link: How to programmatically unplug & replug an arbitrary USB device?

and read through that... it sounds to me like your scanner is completing a task then shutting it's post down. it remains plugged into the PC but the PC does not 'see' it. go to the directory and see if it is still in the directory...

unplugging once the device shuts down the port does nothing. replugging reconnects the electronics and the PC becomes aware of the device which completes one more task. then shuts down its port again.

Dr t

Community
  • 1
  • 1
Dr t
  • 247
  • 4
  • 11