Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2008, 12:46 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Posts: 2
Reputation: 0
bullmike is on a distinguished programming path ahead
Exclamation VB .NET WMI Win32_MappedLogicalDisk ProviderName

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:

Code:
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-19-2008, 3:47 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Nov 2008
Posts: 2
Reputation: 0
bullmike is on a distinguished programming path ahead
Default 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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
providername, unc, vb.net, win32_mappedlogicaldisk, wmi


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 2:11 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.