Submitted By: CJH

Tests letters E-Z (skipping common floppy, system and CD-ROM drive letters) to see if a drive is mapped to that letter. If not, the script sets a variable, MapLtr, to the available drive letter.

Visual Basic
Edit|Remove
Set OFS = CreateObject("Scripting.FileSystemObject")

For x = 65 To 90
  Select Case Chr(x)
  Case "A", "B", "C", "D"
  Case Else
If oFS.DriveExists(Chr(x)) = False Then
    MapLtr = Chr(x)
End If
  End Select
 
If IsEmpty(MapLtr) = False Then
    Exit For
End If
Next

Wscript.Echo MapLtr