Collect network path from current mapping

Hi,

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: http://www.experts-exchange.com/Programming/Misc/Q_22988604.html?sfQueryTermInfo=1+10+30+win32_mappedlogicaldisk

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.

Thanks

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

HKCU\Network\<driveletter>\remotepath

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
Next

Open in new window


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

Coralon
0
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.