Sign in to follow this  
Followers 0
ChrisL

Restarting a USB device

4 posts in this topic

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?

Thanks

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.

Lar.

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)
    EndIf
    
    Sleep (1000 * 60);checks once a minute
WEnd

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

The ini file looks like this

[MonitorDrives]
1=F
2=G
3=H
4=I
5=J
6=K

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  
Followers 0