Sign in to follow this  
Followers 0
Diana (Cda)

Disconnecting a USB flash drive?

5 posts in this topic

This does a great job of bringing up the 'safely remove hardware' dialogue box by clicking rather than right-clicking, which I always prefer <g>:

Run("rundll32.exe shell32.dll,Control_RunDLL hotplug.dll", @SystemDir)

Is there some way, however, to just go right ahead and disconnect a USB flash drive (UFD) directly? On the home computer, the UFD is usu. the E drive but, more importantly it's called "UFD" (yeah, a tad prosaic, but what the heck ...). Can AI disconnect a drive if it has a certain name? That way I hope when other things are connected such as an MP3 player, and the drive letters change again, the script would still work as it's dependent on the drive name and not the drive letter.

Can this be done, by any chance?

Share this post


Link to post
Share on other sites



as far as i believe you dont need to use the safely remove hardware option as long as you device is not set to write caching :-

and even if it is, as long as you dont remove it whilst its still transferring data it's never caused a problem.


Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Share this post


Link to post
Share on other sites

You can use the command line utility "devcon" from Microsoft. Run "devcon status" and parse for the name of flash drive. Then run "devcon remove <device class>" to remove the flash drive. It is totally independent of the drive letter.

This does a great job of bringing up the 'safely remove hardware' dialogue box by clicking rather than right-clicking, which I always prefer <g>:

Run("rundll32.exe shell32.dll,Control_RunDLL hotplug.dll", @SystemDir)

Is there some way, however, to just go right ahead and disconnect a USB flash drive (UFD) directly? On the home computer, the UFD is usu. the E drive but, more importantly it's called "UFD" (yeah, a tad prosaic, but what the heck ...). Can AI disconnect a drive if it has a certain name? That way I hope when other things are connected such as an MP3 player, and the drive letters change again, the script would still work as it's dependent on the drive name and not the drive letter.

Can this be done, by any chance?

Share this post


Link to post
Share on other sites

as far as i believe you dont need to use the safely remove hardware option as long as you device is not set to write caching :-

and even if it is, as long as you dont remove it whilst its still transferring data it's never caused a problem.

Thanks for the info. Just a note, it's strongly recommended to disconnect flash drives esp. with regards to avoiding virus issues. I've read quite a few articles that google pulled up and no matter what, it's more recommended to properly close down a thumb drive before removing than not. I don't mind doing this, though I got lazy and for a year now have not bothered, but after reading about viruses and that one should do this, I'd rather automate the whole thing.

Thanks.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can use the command line utility "devcon" from Microsoft. Run "devcon status" and parse for the name of flash drive. Then run "devcon remove <device class>" to remove the flash drive. It is totally independent of the drive letter.

Hmmm, so AutoIt can't do it without a third party tool ... at all? Just curious. I'll look into this but was hoping to do this with only AI ... (?)

Thanks. :D

Edited by Diana (Cda)

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