WMI Win32_MappedLogicalDisk ProviderName

bullmike

New member
Joined
Nov 18, 2008
Messages
2
Programming Experience
3-5
Hello,

I've created an application that retrieves system information via WMI. In the application I fill a combo box with a list of all the Mapped Network Drives on the PC thats running the application.

On every PC I'm able to obtain the mapped drive letters (using the Name attribute), and in most situations I am able to view each mapped drive's provider name. However, on a few of the PC's that I've tested this application, the ProviderName is not returned.

Here is the code:

VB.NET:
Dim hostName As String = Dns.GetHostName()
Dim strMoniker As String
Dim colNetDrives as Object

strMoniker = "winmgmts:\\" & Trim(hostName)
strQueryNetDrives = "Select * FROM Win32_MappedLogicalDisk"
refWMI2 = GetObject(strMoniker)

        colNetDrives = refWMI2.ExecQuery(strQueryNetDrives)
        If colNetDrives.count = 0 Then
        Else
            For Each refProcess In colNetDrives
                lstnetdrives.Items.Add(refProcess.Name & "   " & refProcess.ProviderName)
            Next
        End If


refProcess.Name will always return the drive letter. On a few of the machines refProcess.ProviderName returns nothing, on the others it returns the UNC path as expected (\\server\share)

What would cause the ProviderName to not return the UNC Path on some PC but not others?

Thanks
Michael Bull
 
A Solution

Well I found a fix for this issue.

Instead of using this
"Select * FROM Win32_MappedLogicalDisk"

I used
"Select * FROM Win32_LogicalDisk WHERE DriveType = 4"


The computers that didn't show the ProviderName now do.


Anyone out there know why?
 
Back
Top