' Get the information on a drive Public Function GetDriveInformation() As Boolean Dim lcSQL As String = "" Dim llSuccess As Boolean = False Dim loQuery As SelectQuery Dim loManagementObject As ManagementObject Dim loSearcher As ManagementObjectSearcher lcSQL = "SELECT FreeSpace,QuotasDisabled,VolumeName,VolumeSerialNumber " + _ "FROM Win32_LogicalDisk WHERE DeviceID=""" + cProviderName + """" Try loQuery = New SelectQuery(lcSQL) loSearcher = New ManagementObjectSearcher(loQuery) For Each loManagementObject In loSearcher.Get() ' Free disk space is irrelevant if per user quota's are enabled If loManagementObject("QuotasDisabled").ToString() <> "true" Then cVolumeSerialNumber = loManagementObject("VolumeSerialNumber") End If Next llSuccess = True Catch loError As Exception cError = loError.Message End Try Return llSuccess End Function Public Function GetDriveSerialNumberWithFileSystemObject() As Boolean Dim llSuccess As Boolean = False Dim loDrive As Object = Nothing Dim loFileSystemObject As Object = Nothing Try ' Create a FileSystemObject object loFileSystemObject = CreateObject("Scripting.FileSystemObject") ' Assign the current drive letter if not specified loDrive = loFileSystemObject.GetDrive(cDrive) ' If the drive is ready If loDrive.IsReady Then cVolumeSerialNumber = Math.Abs(loDrive.SerialNumber) llSuccess = True Else cError = cDriveNotReady End If Catch loError As Exception cError = loError.Message End Try Return llSuccess End Function