Mostly it depends on your choice of scripting languages. Below are two examples one command line batch file the other a vbscript.
in a batch file, you would use a series of If Exists
IF NOT EXIST E:\ NET USE E: \\UNC && GOTO END
IF NOT EXIST F:\ NET USE F: \\UNC && GOTO END
...
:END
You would continue with a IF NOT EXIST statement until you have one for each drive letter you want to use.
with VBScript it is a little easier in some ways.
Dim objFilSys, objNet
Set objFilSys = CreateObject("Scripting.FileSystemObject")
Set objNet = CreateObject("WScript.Network")
'enter all the possible drive letters here.
arrDrives = Array("E:", "F:", "G:", ...)
mapDrive "\\UNCPATH"
Sub mapDrive (strUNC)
For Each i in arrDrives
If Not objFilSys.DriveExists(i) Then
objNet.MapNetworkDrive i,strUNC
exit sub
End If
Next
wscript.echo "There are no drives available"
End Sub
Of course this will work for a temporary solution. However, you will want a more comprehensive solution that includes a consistent mapping scheme that is group related.
I recommend developing a consistent scheme and using the login scripts that delete the drive mappings that do not fit the scheme and then mapping drives according to the new scheme. Further, I suggest consolidating drive mappings whenever possible.
Hope this helps.