Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Integer) As Integer
Public Function firstavaliabledrive() As Char
Dim drives As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim existingdrives() As DriveInfo = DriveInfo.GetDrives()
For Each drv In existingdrives
drives = drives.Replace(drv.ToString.Replace(":\", ""), "")
Next
For i As Integer = drives.Length - 1 To 0 Step -1
If Not IO.Directory.Exists(drives(i) & ":\") Then
Return drives(i)
Exit For
End If
Next
End Function