Total number of drives detected: " & driveList.Count & "
") ' Iterate through each Drive object in the collection For Each d In driveList ' Determine the drive type Select Case d.DriveType Case 0: driveTypeStr = "Unknown" Case 1: driveTypeStr = "Removable" Case 2: driveTypeStr = "Fixed (Hard Drive)" Case 3: driveTypeStr = "Network Share" Case 4: driveTypeStr = "CD-ROM" Case 5: driveTypeStr = "RAM Disk" End Select Response.Write("Drive Letter: " & d.DriveLetter & "") Response.Write("Drive Type: " & driveTypeStr & "
") ' Check if the drive is ready before accessing properties like VolumeName or FreeSpace If d.IsReady Then Response.Write("Volume Name: " & d.VolumeName & "
") Response.Write("Free Space: " & FormatNumber(d.FreeSpace / 1024 / 1024, 0) & " MB
") Else Response.Write("Drive is not ready (e.g., empty CD-ROM or card reader).
") End If Response.Write("
") Next ' Clean up objects Set driveList = Nothing Set fso = Nothing %> ``` --- ### Important Considerations 1. **The `IsReady` Property**: Always check the `IsReady` property of a `Drive` object before attempting to access properties like `TotalSize`, `FreeSpace`, `VolumeName`, or `FileSystemType`. Attempting to access these properties on removable drives that do not contain media (such as an empty CD-ROM drive or an empty USB card reader) will throw a runtime error. 2. **Network Drives**: Network drives will only appear in the collection if they are mapped to a drive letter on the server running the script. 3. **Permissions**: The web server process (e.g., IIS `IUSR` or `NetworkService` account) must have sufficient system permissions to query drive information, otherwise permission denied errors may occur.
YouTip