' Get the information on a drive by the use of ManagementScope Public Function GetDriveInformationManagementScope() As Boolean Dim lcSQL As String = "" Dim llSuccess As Boolean = False Dim loConnectionOptions As ConnectionOptions = Nothing Dim loManagementObject As ManagementObject = Nothing Dim loManagementObjectCollection As ManagementObjectCollection = Nothing Dim loManagementObjectSearcher As ManagementObjectSearcher = Nothing Dim loManagementScope As ManagementScope = Nothing Dim loObjectQuery As ObjectQuery = Nothing ' Reset the values cVolumeSerialNumber = "" nAvailableByte = 0 nFreeSpace = 0 ' Clear the drive If Not ClearDrive() Then Return False End If ' Initialization loConnectionOptions = New ConnectionOptions() ' Connection information loConnectionOptions.Username = cUsername loConnectionOptions.Password = cPassword Try ' Use WMI namespace WMI in which management options will be done If cUsername.Length > 0 Then loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2", loConnectionOptions) Else loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2") End If lcSQL = "SELECT * from Win32_LogicalDisk WHERE DriveType=3 AND VolumeName=""" + cVolumeName + """" ' The ObjectQuery class represents a management query which returns instances or classes loObjectQuery = New ObjectQuery(lcSQL) ' The ManagementObjectSearcher class allows the extration of an object management collection ' in regards to the query specified during the instantiation by the use of the ' ObjectQuery parameter or directly by a string loManagementObjectSearcher = New ManagementObjectSearcher(loManagementScope, loObjectQuery) ' The ManagementObjectCollection represents various object management collections extracted from WMI loManagementObjectCollection = loManagementObjectSearcher.Get() ' If we have found it If loManagementObjectSearcher.Get.Count = 1 Then ' For each drive For Each loManagementObject In loManagementObjectCollection AddDrive(loManagementObject) Next ' Make oRows available oRows = oDataSet.Tables("Temp").Rows() ' Make oRow available oRow = oRows(0) llSuccess = True Else cMessage = oApp.StrTran(cUnableToGainAccessToThisDrive, "##Drive##", "\\" + cIP + "\" + cVolumeName) End If Catch loError As Exception cMessage = loError.Message + " " + lcSQL End Try Return llSuccess End FunctionMost of the code should be easy to understand. Some of its items are related to the framework. But, the main Management Scope design is as is. It's probably at the SQL level that this does not work.
' Get the disk space loDriveInformation.cIP = lcIP loDriveInformation.cVolumeName = lcVolumeName If Not loDriveInformation.GetDriveInformationManagementScope() Then ' Do something End IfThis is the standard code I am using to read the drive information by using a UNC approach. On that drive, it doesn't work.