Jump to content

DriveGetDrive not working ?Get available drive letters


Recommended Posts

Hi,

I am trying to get an available drive letter (a one that is not used by local HD, CDROM, network share or any other) during script run time in order to use that Drive letter to mount a file system

.

I use the

DriveGetDrive("ALL")
to list the existing disks and eliminate if from Z-A order.

I get the letter "Z" even when there is a mounted network share on the dirve ("Z") why ??

Thnaks,

Nadav

Func GetFreeDriveLatter ()
 
$DriveArray = DriveGetDrive("ALL")

;_ArrayDisplay ($DriveArray)

Global  $AtoZ [27] = ["25","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
            
                For $i = 26  to 1 Step -1 
                    For $DriveCount = 1 to $DriveArray[0]
                        If  StringInStr (($DriveArray[$DriveCount]), $AtoZ[$i], 0) Then $AtoZ[$i] = False
                    Next
                Next

;_ArrayDisplay ($AtoZ) 

    For $i1 = 26 to 1 Step -1 
        If $AtoZ[$i1] <> False  Then 
            $MountDrive = StringUpper($AtoZ[$i1])
            ExitLoop
        EndIf   
    Next
    
    
    Return ($MountDrive)    

EndFunc
Link to comment
Share on other sites

i think you have some array problem, its mess in there

try like this and tellme do the Z have false on msgbox?

#Include <Array.au3>
MsgBox(0,"",GetFreeDriveLatter())
Func GetFreeDriveLatter ()
    $DriveArray = DriveGetDrive("ALL")
    $listtemall = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"
    For $x = 1 To $DriveArray[0]
        If StringInStr($listtemall,StringReplace($DriveArray[$x],":","")) Then $listtemall = StringReplace($listtemall,StringReplace($DriveArray[$x],":",""),"False")
    Next
    Return $listtemall
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

@wakillon

Parameters

type Type of drive to find:

"ALL", "CDROM", "REMOVABLE", "FIXED", "NETWORK", "RAMDISK", or "UNKNOWN"

so it shud detect network drive connected (maped) to PC

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...