Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vbs script display mapped network driver

28 views
Skip to first unread message

moonhkt

unread,
Apr 14, 2011, 10:50:18 AM4/14/11
to
Hi All

How to using vbs script display mapped network driver ?

e.g.
M: = \\server_name\path_1

moonhkt

Tom Lavedas

unread,
Apr 14, 2011, 1:03:44 PM4/14/11
to

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

Tom Lavedas

unread,
Apr 14, 2011, 1:17:01 PM4/14/11
to
On Apr 14, 1:03 pm, Tom Lavedas <tglba...@verizon.net> wrote:
> On Apr 14, 10:50 am, moonhkt <moon...@gmail.com> wrote:
>
> > Hi All
>
> > How to using vbs script display mapped network driver ?
>
> > e.g.
> > M: = \\server_name\path_1
>
> > moonhkt
>
> Here's one way I know of ...
>
{code omitted}

> 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

moonhkt

unread,
Apr 15, 2011, 1:20:24 AM4/15/11
to

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

0 new messages