HockeyFan Posted December 19, 2006 Share Posted December 19, 2006 (edited) Does someone know about a command or script that can find the first available drive letter? I know about using the DriveMapAdd command, and using the "*" parameter to assign the first unused drive letter, but the Help file also states that "If there was an error using "*" then a blank string "" will be returned." I want to be able to determine what the error is if one is returned. Any help would be much appreciated Edited December 19, 2006 by HockeyFan Link to comment Share on other sites More sharing options...
MHz Posted December 19, 2006 Share Posted December 19, 2006 (edited) Example from DriveGetDrive in the helpfile. $var = DriveGetDrive( "all" ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf That will show you used drives so you can work out the next available drive letter. Edit: Added "letter". Edited December 19, 2006 by MHz Link to comment Share on other sites More sharing options...
NeoFoX Posted December 19, 2006 Share Posted December 19, 2006 (edited) $drive = StringSplit("c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",",1) For $i = 1 to $drive[0] step +1 $var = DriveStatus( $drive[$i] & ":" ) If $var = "INVALID" Then MsgBox(1,"Free:","The first free letter: " & $drive[$i]) Exit EndIf Next Neo Edited December 19, 2006 by NeoFoX [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center] Link to comment Share on other sites More sharing options...
HockeyFan Posted December 19, 2006 Author Share Posted December 19, 2006 Example from DriveGetDrive in the helpfile. $var = DriveGetDrive( "all" ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf That will show you used drives so you can work out the next available drive letter. Edit: Added "letter". Yes, I saw that example...but I'm not wanting to display this during the execution of the script, nor am I wanting to select the drive letter. I was just hoping to find some code that found the first available drive letter and then used that drive letter to map a network connection. Link to comment Share on other sites More sharing options...
HockeyFan Posted December 19, 2006 Author Share Posted December 19, 2006 $drive = StringSplit("c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",",1) For $i = 1 to $drive[0] step +1 $var = DriveStatus( $drive[$i] & ":" ) If $var = "INVALID" Then MsgBox(1,"Free:","The first free letter: " & $drive[$i]) Exit EndIf Next Neo Thanks Neofox...this looks like it could work for me! 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