Enumerate mapped drives using WMI (VBScript)

This code can be found in Chapter 7 of Windows XP Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' From the book, "Windows XP Cookbook"
' ISBN: 0596007256

strComputer = "."
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colDrives = objWMI.ExecQuery("select * from Win32_MappedLogicalDisk")
WScript.Echo "Mapped Drives:"
for each objDrive in colDrives
 WScript.Echo " Device ID: " & objDrive.DeviceID
 WScript.Echo " Volume Name: " & objDrive.VolumeName
 WScript.Echo " Session ID: " & objDrive.SessionID
 WScript.Echo " Size: " & objDrive.Size
 WScript.Echo
next

This code has been viewed 2462 times.

New from the creators of TechTasks.com: StatSheet.com