Sign in to follow this  
Followers 0
firestrife23

Automatic mapping a drive

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Thanks for quick response, It turned out I was using incorrect login.

Share this post


Link to post
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
Sign in to follow this  
Followers 0