By David Wiseman (Administrator)Created 10 Dec 2007, Modified 23 Feb 2008
My Rating:
Vote
Rating:
Not Rated
Views:19987
Downloads:332

Remove all mapped network drives

Language:  VBScript

Compatibility

Windows XP Yes Windows 2003 Yes
Windows 2000 Yes Windows NT Unknown
Vista Unknown Windows 2008 Unknown
Description

Remove all mapped network drives.


Notes
object.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile]) WshNetwork object. http://msdn2.microsoft.com/en-us/library/d16d7wbf.aspx strName String value indicating the name of the mapped drive you want to remove. The strName parameter can be either a local name or a remote name depending on how the drive is mapped. bForce Optional. Boolean value indicating whether to force the removal of the mapped drive. If bForce is supplied and its value is true, this method removes the connections whether the resource is used or not. bUpdateProfile Optional. String value indicating whether to remove the mapping from the user's profile. If bUpdateProfile is supplied and its value is true, this mapping is removed from the user profile. bUpdateProfile is false by default.  
Code

Line Numbers: On  Off      Plain Text
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
	' Force Removal of network drive and remove from user profile 
	' objNetwork.RemoveNetworkDrive strName, [bForce], [bUpdateProfile]
	objNetwork.RemoveNetworkDrive colDrives.Item(i),TRUE,TRUE
Next

 


Got a useful script? Click here to upload!


 

  Post Comment
Order By:  
User Comments
      
Be the first to post a comment!