Avatar of georgedschneider
Flag for United States of America

asked on 

VBScript to Remove mapped Drives

'm running the following Script to remove all mapped drives as part of a logon script that is applied through a GPO.  I'm receiivng an Windows Scripting Host error message on logon at line3, char 1 that the local device s already in use.  

In addition to this script i have in the user's property in AD  asetting that specifies that the H drive is mapped t a specific location for a users home folder will this cause a problem?

What I basically want to accoumplish is to removed any mapped network drive connection that may exist with the exception of the users home directory.  Is this possible and what am I doing worng?
Set objNetwork = CreateObject("Wscript.Network")
On Error Resume Next
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
    objNetwork.RemoveNetworkDrive colDrives.Item(i)

Open in new window

VB Script

Avatar of undefined
Last Comment

8/22/2022 - Mon