VB Quicktakes - Map Drives

If you have the net.exe (which you should have if you are using NT) you can use the code below to Map and unmap drive letters.


Public Sub MapDrive(DriveLetter As String, UNCPath As String)
On Error GoTo errHandler
   Shell "net use " & DriveLetter & ": " & UNCPath

errHandler:
   MsgBox Err.Number & " " & Err.Description
End Sub

Public Sub UnMapDrive(DriveLetter As String) On Error GoTo errHandler Shell "net use " & DriveLetter & ": /d" errHandler: MsgBox Err.Number & " " & Err.Description End Sub
About this page: