Jump to content
Sign in to follow this  

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, "\\\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) & ':'            
    $aArray[0] = UBound($aArray) - 1    
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.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...