Sign in to follow this  
Followers 0
grunewald6

Get drive letter from share name?

4 posts in this topic

Does anyone know a way to determine what drive letter a remote share is located on? I want to be able to look at a share and determine how much space is left on the drive that that share is located on but will not always know the drive letter beforehand to use the DriveSpaceFree command. Thanks in advance for any suggestions.

Share this post


Link to post
Share on other sites



Look at DriveGetDrive and DriveGetType in the documentation for more ideas.


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

Does anyone know a way to determine what drive letter a remote share is located on?

What you need to look at is the function DriveMapGet()

There you go:

$Share = "\\servername\sharename"


For $i = 65 To 90 ; ASC("A")=65, ASC("Z")=90
    $next = Chr($i) & ":"
    If DriveGetType($next) = "Network" Then
        If DriveMapGet($next) = $Share Then
            MsgBox(0, "Map Searcher", $Share & " is mapped to drive letter " & $next & ": ...")
            Exit
        EndIf
    EndIf
Next

MsgBox(0, "Map Searcher", "Currently there is no drive letter mapped to " & $Share)

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Thanks Rudi, I was able to modify your code to fit my purpose. Posting here to help out others.

$ShareOld = "SERVEROldShare"
$ShareNew = "SERVERNewShare"
For $i = 65 To 90 ; ASC("A")=65, ASC("Z")=90
    $next = Chr($i) & ":"
    If DriveGetType($next) = "Network" Then
        If DriveMapGet($next) = $ShareOld Then
   DriveMapDel($next)
   Sleep(1000)
   DriveMapAdd($next, $ShareNew, 1)
            Exit
        EndIf
    EndIf
Next

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