cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ejensen
Engaged Sweeper III
would be nice to know what path network drives are mapped to.

also, would be nice to see free space as a percentage.
1 REPLY 1
ejensen
Engaged Sweeper III
here is part of a script that should get us started on adding mapped drives for users on a computer.
I will dig through some other scripts to see what else might be needed.

This only shows persistent mapped drives I believe.


'Searching the registry for stored profiles
strKeyPath = ""
oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
' Filtering out some well-known SIDs
Select Case subkey
Case ".DEFAULT"
Case "S-1-5-18" 'Local System
Case "S-1-5-19" 'Local Service
Case "S-1-5-20" 'Network service
Case Else
If Instr(subkey, "_Classes") = 0 Then
'Searching for mapped drives
strKeyPath2 = subkey & "\Network"
oReg.EnumKey HKEY_USERS, strKeyPath2, arrSubKeys2
For Each subkey2 in arrSubKeys2
If subkey2 <> "" Then
'Found mapped drive
'Searching for the username matching the SID
DeviceID = ""
ProviderName = ""
MapUserName = ""
MapUserDomain = ""
ConnectAs = ""
Set colItems = objWMIService.ExecQuery("Select Name, Domain from Win32_UserAccount where SID = '" & subkey & "'",,48)
If colItems <> "" Then
' Found local user
For Each objItem in colItems
MapUserName = objItem.Domain & "\" & objItem.Name
Next
End If
If MapUserName = "" Then
'Searching the registry for domain user info
strKeyPath3 = subkey & "\Software\Microsoft\Windows\CurrentVersion\Explorer"
oReg.GetStringValue HKEY_USERS, strKeyPath3, "Logon User name", MapUserName
strKeyPath4 = subkey & "\Volatile Environment"
oReg.GetStringValue HKEY_USERS, strKeyPath4, "USERDNSDOMAIN", MapUserDomain
MapUserName = MapUserName & "@" & LCase(MapUserDomain)
End If
'Reading mapped drive details
DeviceId = Ucase(subkey2)
strKeyPath5 = strKeyPath2 & "\" & subkey2
oReg.GetStringValue HKEY_USERS, strKeyPath5, "RemotePath", ProviderName
oReg.GetStringValue HKEY_USERS, strKeyPath5, "UserName", ConnectAs
FileSystem = ""
FreeSpace = 0
Size = 0
form_input = "mapped^^^" & DeviceID & "^^^" & FileSystem & "^^^" & FreeSpace & "^^^" & ProviderName & "^^^" _
& Size & "^^^" & MapUserName & "^^^" & ConnectAs & "^^^"
entry form_input,comment,objTextFile,oAdd,oComment
form_input = ""
End If 'subkey2 <> ""
Next 'subkey2 in arrSubKeys2
End If 'Instr(subkey, "_Classes") = 0
End Select
Next ' subkey In arrSubKeys