+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, Force Remove Mapped Drive in Coding and Web Development; Hi All Simple VBScript I currently use to remove network drives at the end of a session on a logoff ...
  1. #1
    M0MST
    Guest

    Force Remove Mapped Drive

    Hi All

    Simple VBScript I currently use to remove network drives at the end of a session on a logoff script. However It currently only removes 1 or 2 drives. I remember many moons ago there was a force disconnect drive using wscript but I cannot for the life of me remember it

    Any pointers?

    Code:
    Dim objNetwork
    Set objNetwork = CreateObject("WScript.Network")
    
    on error resume next
    objNetwork.RemoveNetworkDrive "p:"
    objNetwork.RemoveNetworkDrive "z:"
    objNetwork.RemoveNetworkDrive "r:"
    objNetwork.RemoveNetworkDrive "u:"
    objNetwork.RemoveNetworkDrive "w:"
    objNetwork.RemoveNetworkDrive "t:"

  2. #2
    noxigen's Avatar
    Join Date
    May 2013
    Location
    Nashville, TN USA
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Just set the Force argument to True.
    RemoveNetworkDrive Method


    Code:
    objNetwork.RemoveNetworkDrive "p:", True

  3. #3

    Join Date
    Dec 2006
    Location
    Preston, Lancashire
    Posts
    126
    Thank Post
    13
    Thanked 12 Times in 11 Posts
    Rep Power
    18
    I'm a little late on this, but easiest way I found to remove all drive mappings is:

    Set clDrives = WshNetwork.EnumNetworkDrives
    For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
    Next

SHARE:
+ Post New Thread

Similar Threads

  1. Share a mapped drive
    By Samson in forum Wireless Networks
    Replies: 4
    Last Post: 3rd May 2007, 02:35 PM
  2. Issues with two new Dell PC's mapping drives.
    By tosca925 in forum Wireless Networks
    Replies: 1
    Last Post: 18th January 2007, 12:13 AM
  3. Replies: 7
    Last Post: 27th November 2006, 11:26 AM
  4. Accssing mapped drives in word
    By Uraken in forum Windows
    Replies: 7
    Last Post: 19th October 2006, 07:24 AM
  5. Replies: 4
    Last Post: 7th December 2005, 08:09 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •