Removable drives

  • Thread starter Thread starter MarkS
  • Start date Start date
M

MarkS

Hi,
Is there a piece of code to check that a removable drive
is there or not.

Thanks MarkS
 
Couple of functions you should be able to adapt

Tim


From:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht
ml/jscoldrives.asp

Function ShowDriveList
Dim fso, d, dc, s, n
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
n = ""
s = s & d.DriveLetter & " - "
If d.DriveType = 3 Then '
n = d.ShareName
ElseIf d.IsReady Then
n = d.VolumeName
Else
n = "[Drive not ready]"
End If
s = s & n & vbcrlf
Next
ShowDriveList = s
End Function

Function ShowDriveType(drvpath)
Dim fso, d, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(drvpath)
Select Case d.DriveType
Case 0: t = "Unknown"
Case 1: t = "Removable"
Case 2: t = "Fixed"
Case 3: t = "Network"
Case 4: t = "CD-ROM"
Case 5: t = "RAM Disk"
End Select
ShowDriveType = "Drive " & d.DriveLetter & ": - " & t
End Function
 
Back
Top