So why not just fix the "other" drive to an unused mapping? "R:" or something?

If you really want to go down the random drive mapping route, do it this way:
  • Assign all possible letters to a variable.
  • Use the left-most letter to map the drive
  • Strip the letter that you have just used off the string so that it won't be used for the next mapping


Here is a simple example of how to do it (untested). Drive mappings will be assigned to drives Q:, R:, S: and T: in the order that they appear in the script. If you should run out of letters, the mapping will be assigned to the first unused drive letter:
Code:
Dim $sDrives


$sDrives="Q:R:S:T:"

If InGroup("group a")
MapDrive(Left($sDrives,2),"\\some\share")
$sDrives=SubStr($sDrives,3)
EndIf

If InGroup("group b")
MapDrive(Left($sDrives,2),"\\some\other share")
$sDrives=SubStr($sDrives,3)
EndIf


Function MapDrive($sDriveLetter,$sSharePath)
If $sDriveLetter
; Delete existing mapping
Use $sDriveLetter /delete /persistent
; *** Add error checking here ***
Else
$sDriveLetter="*" ; No drive letter - select one at random
EndIf
; Create new mapping
Use $sDriveLetter $sSharePath
; *** Add error checking here ***
EndFunction