none
Adaptar script para remover todos os drives de rede RRS feed

  • Pergunta

  • Pessoal,

    Estou utilizando o script a seguir para mapear as unidades de rede da empresa.

    Gostaria de adapta-lo para que ao invés de deixar explícito qual a unidade a ser desconectada, fosse desconectado todos os drives.

    Alguém poderia em auxiliar na adptação deste script?

    A seguir o código:

    '==========================================================================

    'VBScript:  AUTHor:
    'NAME: <ti.vbs>

    'COMMENT:
    '1.Script de logon do Active Directory
    '2.Mapeia drivers de rede
    'Referências: http://www.microsoft.com/technet/scriptcenter
    '==========================================================================
    Option Explicit
    On Error Resume Next
     
    Dim WSHNetwork
    Dim objFSO
    Dim strUserName
    Dim strUserDomain
    Dim ObjGroupDict
    Dim objShell
    Dim colUsrEnvVars
    Dim objNetwork
    Dim objADSysInfo
    Dim strComputer
    Dim objWMIService


    Dim sh_DEPTO
    Dim sh_TI


    sh_DEPTO = "\\SBRINFDC01\DEPTO$"
    sh_TI = "\\SBRINFDC01\TI$"

    Set WSHNetwork = WScript.CreateObject("WScript.Network")
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    strUserName = WSHNetwork.UserName
    strUserDomain = WSHNetwork.UserDomain

    Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
    Set objShell = WScript.CreateObject("WScript.Shell")

    Set colUsrEnvVars = objShell.Environment("USER")
    Set objADSysInfo = CreateObject("ADSystemInfo")

    Set objNetwork = CreateObject("Wscript.Network")

    If objFSO.FolderExists("F:\") Then
     WSHNetwork.RemoveNetworkDrive "F:"
    End If
    WSHNetwork.MapNetworkDrive "F:", sh_TI

    If objFSO.FolderExists("G:\") Then
     WSHNetwork.RemoveNetworkDrive "G:"
    End If
    WSHNetwork.MapNetworkDrive "G:", sh_DEPTO

    Function MemberOf(ObjDict, strKey)
    MemberOf = CBool(ObjGroupDict.Exists(strKey))
    End Function

    Function CreateMemberOfObject(strDomain, strUserName)
    Dim objUser, objGroup
    Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
    CreateMemberOfObject.CompareMode = vbTextCompare
    Set objUser = GetObject("WinNT://" _
    & strDomain & "/" _
    & strUserName & ",user")
    For Each objGroup In objUser.Groups
    CreateMemberOfObject.Add objGroup.Name, "-"
    Next
    Set objUser = Nothing
    End Function

    quarta-feira, 29 de junho de 2011 14:06

Respostas