snyperj
asked on
Getting the name of a mapped share, using vbs
Is there a way I can use VBS to list the network mappings for the current user and the names of the shares?
For example, say that a network user can see network drives J: , X: and M: when they login.
I would like to have a script that when clicked on returns something similar to:
\\SERVER001\SALES\ as J:
\\SERVER002\ENG\ as X:
\\ERDMAIN\JSmith$\ as M:
Thanks!
For example, say that a network user can see network drives J: , X: and M: when they login.
I would like to have a script that when clicked on returns something similar to:
\\SERVER001\SALES\ as J:
\\SERVER002\ENG\ as X:
\\ERDMAIN\JSmith$\ as M:
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Simple:
strComputer = "." ' Local Computer
SET objWMI = GETOBJECT("winmgmts:\\" & strComputer & "\root\cimv2")
SET colDrives = objWMI.ExecQuery("select * from Win32_MappedLogicalDisk")
FOR EACH objDrive in colDrives
WScript.Echo objDrive.ProviderName & " as " & objDrive.Name
NEXT
I know you asked for a VBS script, but just in case you aren't aware, there is a simple command that you can do in a BAT file or a command line to show this info as well, give it a try. If you are integrating into a larger VBS effort etc then feel free to ignore this, but figured no harm in passing it along.
NET USE
~bp
ASKER
Thanks to all who answered
Open in new window