ARampton
asked on
VBScript to list Unavailable Mapped Drives
I have been using some simple VBScript to identify a users mapped drives but have found all sample scripts I have tried omit any Mapped Drive that is Unavailable (as listed in CMD Net Use)
Because I need to remove such drives before remapping how can I identify any that are already unavailable?
Sample script lists drives nicely but only those with a Status of OK:
Any suggestions on modifying this script or using another method?
Because I need to remove such drives before remapping how can I identify any that are already unavailable?
Sample script lists drives nicely but only those with a Status of OK:
On Error Resume Next
Dim objNetwork, objDrives, objShell
Dim strSubst, strSubstVal, strSubstName, strEnumDrive
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("Shell.Application")
Set objDrives = objNetwork.EnumNetworkDrives
For i = 0 to objDrives.Count - 1 Step 2
strSubst = objShell.NameSpace(objDrives.Item(i) & Chr(92)).Self.Name
strSubstVal = inStr(1,strSubst, Chr(40)) - 2
strSubstName = Mid(strSubst, 1, strSubstVal)
strEnumDrive = strEnumDrive & "Drive Letter: " & objDrives.Item(i) & vbCrlF & _
"Drive Name: " & strSubstName & vbCrlF & "Drive Path: " & _
objDrives.Item(i+1) & vbCrLf & vbCrLf
Next
MsgBox strEnumDrive ,, "All mapped Drives"
Any suggestions on modifying this script or using another method?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Used Registry entries to identify mapped drives and normal objNetwork.RemoveNetworkDr ive to remove old drives
Removing drives errors but does allow remapping after next logon
Removing drives errors but does allow remapping after next logon
ASKER
First script shows just what I need, second script is faster but omits anything Unavailable
Now I have identified which mapped drives are Unavailable I can't find any way of scripting their removal
Normal delete using "objNetwork.RemoveNetworkD
Is there a way to remove an identified objItem.LocalName as found in your first script?