Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to show other machines mapped drives

Status
Not open for further replies.

rmgates

Technical User
Jun 28, 2012
24
US
We have a simple script to input a machine name and list that machines mapped drives:

strComputer = "computername"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 4")
For Each objDrive in colDrives
Wscript.Echo "Drive letter: " & objDrive.DeviceID
Wscript.Echo "Network path: " & objDrive.ProviderName
Next

If I run and neter my machine it returns info, when I run for any other machine on domain, it returns nothing. Rghts/permission issue?
Ideas?
 
Not sure. I believe the Win32_LogicalDisk method only enumerates those drives that were mapped using the WMI or manually via the Windows environment. I like to enumerate the current user's Network reg key.

Code:
CONST HKCU = &H80000001
strComputer = "somename"
set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
objReg.EnumKey HKCU, "Network", arrDriveLetters

for each strDriveLetter in arrDriveLetters
   objReg.GetStringValue HKCU, "Network\" & strDriveLetter, "RemotePath", strPath
   msgbox "Drive Letter: " & strDriveLetter & vbNewLine & "Path: " & strPath
next

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top