Remove All Mapped Drives in VBScript

On Error Resume Next

Set objNetwork = CreateObject("Wscript.Network")

Set colDrives = objNetwork.EnumNetworkDrives

For i = 0 to colDrives.Count-1 Step 2
    objNetwork.RemoveNetworkDrive colDrives.Item(i)
Next

Little syntax help:

objNetwork.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])

Key:

objNetwork : A WScript.Network object

strName : The mapped drive you want to remove.

bForce : Force the removal of the mapped drive (TRUE/FALSE).

bUpdateProfile : Remove the mapping from the user’s profile (TRUE/FALSE).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s