Iznogoud Posted January 31, 2007 Share Posted January 31, 2007 Maybe a stupid question, but is there a way to find the driveletter of an USB device wich is plugged in? I have some people who want to make a backup to an USB device. I could put the driveletter wich it have it now in the script, but as you know this will not guarantee for the future. I know there are some programs wich can detect the USB device and i really would like to know how i can accomplish this with AutoIT also. Anyone any idea? Link to comment Share on other sites More sharing options...
redfive19 Posted January 31, 2007 Share Posted January 31, 2007 Someone posted a DISKPART UDF in the example scripts forum. However, as of now, it cannot return the type of drive you're using. I did something very similar to this a few months back but I went about it in a round about way. I basically did a DISKPART dump to a txt file and then had AutoIt read lines from that text file. It would return the disk type that it read from the outputted DISKPART log. This is probably NOT the way to do it. I don't know if there are WMI calls that would be a lot easier. Link to comment Share on other sites More sharing options...
BigDod Posted January 31, 2007 Share Posted January 31, 2007 Here is a start $var = DriveGetDrive("REMOVABLE") If Not @error Then MsgBox(4096, "", "Found " & $var[0] & " drives") MsgBox(4096, "Drive ", $var[$var[0]]) EndIf Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Iznogoud Posted January 31, 2007 Author Share Posted January 31, 2007 Here is a start $var = DriveGetDrive("REMOVABLE") If Not @error Then MsgBox(4096, "", "Found " & $var[0] & " drives") MsgBox(4096, "Drive ", $var[$var[0]]) EndIf This is a start, yes. But i am a big sucker at arrays :"> Most new PC's got internal card readers wich are detected also as REMOVABLE, so is it possible to detect te drives and check for the name wich i can predefine? Ex. USB stick name is USBDISKPRO and the drive letter is P:\, is it possible to find out just this specific driveletter? Link to comment Share on other sites More sharing options...
BigDod Posted January 31, 2007 Share Posted January 31, 2007 (edited) You could use DriveGetLabel on the removeable drives to see which one matches.Edit - added code$var = DriveGetDrive("REMOVABLE") If Not @error Then MsgBox(4096, "", "Found " & $var[0] & " drives") For $i = 1 To $var[0] If DriveGetLabel($var[$i]) = "test" Then MsgBox(4096, "", "Removable disk is " & $var[$i]) EndIf Next EndIf Edited January 31, 2007 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now