Jump to content
Sign in to follow this  

Restarting a USB device

Recommended Posts

What I want to do is to restart a stopped USB device.

The thing is that a USB card reader occasionally drops out and the drive letters dissapear.

What I would like to do is to be able to restart the device, or force windows to rescan the hardware.

If I stop the device manually I have this status in device manager....

Windows cannot use this hardware device because it has been prepared for "safe removal", but it has not been removed from the computer.

Telling device manager to rescan for devices doesn't work.

Do any of you clever people know of a call that can be made to force windows to restart the device?


Share this post

Link to post
Share on other sites

I gave up on setupapi.dll + GUID + PVOID hell... This can be done without devcon.exe if you are brave enough to learn setupapi.dll.


Well thanks for looking..

This is what I have so far using Devcon which seems to work OK

Fileinstall ("Devcon.exe", @tempdir & "\Devcon.exe",1)

$iniFile = "DriveMonitor.ini"

$DriveList= IniReadSection($iniFile,"MonitorDrives") 

While 1
    If NOT DrivesAreOK() then   
        RunWait (@tempdir & "\Devcon restart USB\ROOT*", @tempdir, @sw_hide)
    Sleep (1000 * 60);checks once a minute

Func DrivesAreOK()
    Local $dOK = 1
    For $i = 1 to Ubound ($DriveList) -1
        If DriveStatus($DriveList[$i][1] & ":") = "INVALID" then $dOK = 0
    Return $dOK 

The ini file looks like this


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...