Jump to content

Automatic mapping a drive


Recommended Posts

I'm trying to get my script to determine free drive letter and automatically map the drive. For some reason DriveMapAdd dislike the variable "$SetDrive" unless I set it to something else like "G:"

#include <Array.au3>

$FreeDriveList = GetFreeDriveLetters()
$AvailableDrive = _ArrayMin($FreeDriveList)
$SetDrive = $AvailableDrive

$Map = DriveMapAdd ( $SetDrive, "\\192.168.16.5\Dropbox", 0, "domain\user", "password")
$ErrSav = @Error
$ExtSav = @Extended
MsgBox(64, "Debug", "Results of DriveMapAdd:" & @CRLF & "Return = " & $map & @CRLF & "Error = " & $ErrSav & @CRLF & "Extended = " & $ExtSav)

Func GetFreeDriveLetters()
    Dim $aArray[1]
    For $x = 67 To 90
        If DriveStatus(Chr($x) & ':\') = 'INVALID' Then
            ReDim $aArray[UBound($aArray) + 1]
            $aArray[UBound($aArray) - 1] = Chr($x) & ':'            
        EndIf
    Next
    $aArray[0] = UBound($aArray) - 1    
    Return($aArray)
EndFunc
Edited by firestrife23
Link to comment
Share on other sites

Hi firestrife,

tested it an d works fine for me.

If I display the array I get a list of G: or J: or X:

So this should be fine.

Even if I just assign the return from _ArrayMin to $SetDrive it works fine.

:unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
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...