Remove all drives accept home folder

Our users home folder is set in the active directory.
I have a logon script that removes all drives and remaps them depending on computer location.

This removes the home folder aswel.
How do I change this code to ignore the U: drive?

' =============================================================================
' Force removal of all network drives
' =============================================================================
On Error Resume Next
DIM objNetwork,colDrives,i
 
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
 
For i = 0 to colDrives.Count-1 Step 2
	objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE
Next

Open in new window

Antonio KingIT ManagerAsked:
Who is Participating?
 
Michael PfisterConnect With a Mentor Commented:
Is this what you are looking for? HTH
' =============================================================================
' Force removal of all network drives
' =============================================================================
On Error Resume Next
DIM objNetwork,colDrives,i
 
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
 
For i = 0 to colDrives.Count-1 Step 2
    If colDrives.Item(i) <> "U:" Then
        objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE
    End If
Next

Open in new window

0
 
Antonio KingIT ManagerAuthor Commented:
Perfect
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.