Collect network path from current mapping


I'm searching for a vb script that can collect the network path (\\servername\share) from an exsisting network mapping collected from WMI.

I have found an article that basicly does the tric here for all drivers:

I prefer to use the win32_mappedlogicaldisk and then the providername like mentioned in the article above (or if you have a better suggestion ;-)

But I only need to have the network path from the i:\ drive (so not all drives / instances.

Other info:
- the script will run locally as the current user

Please help.


Who is Participating?
If you aren't married to using WMI to get it, it is stored in HKCU.


On the other hand, I slapped this together and tested it.  I do not know if a regular user would have access to it or not.  I know a lot of the WMI functions require admin access, but some of the query functions don't.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT ProviderName,Name FROM Win32_MappedLogicalDisk where name like 'L:'",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_MappedLogicalDisk instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "ProviderName: " & objItem.ProviderName

Open in new window

The key is the Like part of the query, where you would specify the drive letter.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.