How to using vbs script display mapped network driver ?
e.g.
M: = \\server_name\path_1
moonhkt
Here's one way I know of ...
' Local computer - can be named remote (with admin privleges)
sComputer = "."
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\cimv2")
sQry = "Select * from Win32_MappedLogicalDisk"
Set colItems = objWMI.ExecQuery(sQry)
For Each objItem in colItems
WSH.Echo objItem.DeviceID, "=", objItem.ProviderName
Next
It can also be done with FSO Drives collection, I think.
_____________________
Tom Lavedas
> It can also be done with FSO Drives collection, I think.
> _____________________
> Tom Lavedas
And the FSO approach is simpler ...
Set dc = CreateObject("Scripting.FileSystemObject").Drives
For Each d in dc
If d.DriveType = 3 Then
wsh.echo d.DriveLetter ,"=", d.ShareName
End If
Next
The WMI approach does offer a wealth of other information; like
freespace, size volume name, etc.; but that wasn't the question, was
it?
_____________________
Tom Lavedas
Option Explicit
'~~ 2011/04/15
Dim dc , d
Dim sComputer , objWMI , colItems, objItem, sQry
Set dc = CreateObject("Scripting.FileSystemObject").Drives
For Each d in dc
If d.DriveType = 3 Then
wsh.echo d.DriveLetter ,"=", d.ShareName
End If
Next
' Local computer - can be named remote (with admin privleges)
sComputer = "."
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& sComputer & "\root\cimv2")
sQry = "Select * from Win32_MappedLogicalDisk"
Set colItems = objWMI.ExecQuery(sQry)
For Each objItem in colItems
WSH.Echo objItem.DeviceID, "=", objItem.ProviderName
Next
using ProviderName display "null"
c:\temp>mapping
F = \\MPPD2\home$\
I = \\MPPD002\prod$
S = \\MPPDG02\ishare$
U = \\MPPDG02\ushare$
F: = null
I: = null
S: = null
U: = null