Announcement

Collapse
No announcement yet.

Disconnect Network Drive Mappings

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disconnect Network Drive Mappings

    I am looking for a VBS that I can apply in AD so when the user logs in, it will identify any invalid drive connections and disconnect them.
    Some I have found base it upon drive letter and name. Drive letter in my workplace is not always a constant. I need to identify by UNC or \\server\share. The problem I am having is I have several clients on a WLAN and the invalid drive mappings make the PC hang every so often when it looks to contact them periodically. So I have been going to the clients as they call and fixing this issue.
    Any help to automate the process would be appreciated.

    Thanks

  • #2
    Re: Disconnect Network Drive Mappings

    Code:
    Set objNetwork = CreateObject("WScript.Network")
    
    ' Disconnect all(!!!) Network Mappings
    If objNetwork.EnumNetworkDrives.Count <> 0 Then
       CreateObject("WScript.Shell").Run _
         "cmd.exe /c COLOR 72 & title Disconnecting Network Mappings & " _
         & "(echo.|NET.exe USE * /d /y )", 0, true
    End If
    
    ' Map drive
    ' objNetwork.MapNetworkDrive "J:", "\\server\share name", False
    \Rems
    Last edited by Rems; 25th September 2010, 14:18.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X