meekaah Posted August 28, 2007 Share Posted August 28, 2007 Hi, im looking for a way to find a drive letter from a drive label I want to be able to find a specific drive letter that will allways have the same label "MYPHONE" so i was thinking to do a loop through all usb removable devices with $drive=DriveGetDrive( "removable" ) and get the labels with DriveGetLabel($drive) but cant find a way please help Link to comment Share on other sites More sharing options...
meekaah Posted August 28, 2007 Author Share Posted August 28, 2007 something like $var = DriveGetDrive( "removable" ) For $i = 1 to $var[0] $name = DriveGetLabel($var[$i]) Next Do Sleep(100) Until $name = "MYPONE" MsgBox(64,"Info", "Found!") But it doesnt work.. Link to comment Share on other sites More sharing options...
weaponx Posted August 28, 2007 Share Posted August 28, 2007 (edited) something like $var = DriveGetDrive( "removable" ) For $i = 1 to $var[0] $name = DriveGetLabel($var[$i]) Next Do Sleep(100) Until $name = "MYPONE" MsgBox(64,"Info", "Found!") But it doesnt work.. Loops don't run in parallel. That second loop will do nothing until the first completes. $var = DriveGetDrive( "removable" ) For $i = 1 to $var[0] $name = DriveGetLabel($var[$i]) If $name = "MYPONE" Then MsgBox(64,"Info", "Found!") EndIf Next Edited August 28, 2007 by weaponx Link to comment Share on other sites More sharing options...
meekaah Posted August 28, 2007 Author Share Posted August 28, 2007 AH thanks, i knew there was a problem of this kind i had to modify your code a little bit but it works perfet thanks $var = DriveGetDrive( "removable" ) $usb = "MYPHONE" For $i = 1 to $var[0] $name = DriveGetLabel($var[$i]) If $name = $usb Then MsgBox(64,"Info", "Found!") EndIf Next Link to comment Share on other sites More sharing options...
meekaah Posted August 28, 2007 Author Share Posted August 28, 2007 (edited) Oh but now that i actually think of it, how would i know WHICH letter drive is associated to "MYPHONE" label, once it is found...? EDIT ok nevermnd i dont take the time to think a little bit , my bad $var = DriveGetDrive( "removable" ) $usb = "MYPHONE" For $i = 1 to $var[0] $name = DriveGetLabel($var[$i]) If $name = $usb Then MsgBox(64,"Info", "MYPHONE found in "& $var[$i] & "\") EndIf Next Edited August 28, 2007 by meekaah 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