none
Problemas com script logon .VBS RRS feed

  • Pergunta

  • Pessoal,

    Estou utilizando um script que mapeia as unididades compartilhadas de acordo com o grupo do usuário. Porém ao executar o script eu recebo a seguinte mensagem:
    "A propriedade da pasta não pode ser encontrada em cache"

    Essa mensagem é referente a linha que está em negrito no script postado abaixo.

    Const GG_1 = "cn=administrativo"
    Const GG_2 = "cn=comercial"
    Const GG_3 = "cn=coordenação"
    Const GG_4 = "cn=diretoria"
    Const GG_5 = "cn=financeiro"
    Const GG_6 = "cn=operação"
    Const GG_7 = "cn=planejamento"
    Const GG_8 = "cn=relatorios"
    Const GG_9 = "rh"
    Const GG_10 = "selecao"
    Const GG_11 = "TI"
    
    
    Set wshNetwork = CreateObject("WScript.Network")
    Set oDrives = WshNetwork.EnumNetworkDrives
    Set ADSysInfo = CreateObject("ADSystemInfo")
    'wscript.echo ADSysInfo.UserName
    Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
    DriveMapper "J:"
    DriveMapper "K:"
    DriveMapper "L:"
    DriveMapper "M:"
    DriveMapper "N:"
    DriveMapper "O:"
    DriveMapper "P:"
    DriveMapper "Q:"
    DriveMapper "R:"
    DriveMapper "T:"
    DriveMapper "U:"
    DriveMapper "V:"
    DriveMapper "W:"
    DriveMapper "X:"
    DriveMapper "Y:"
    DriveMapper "Z:"
    
     
    
    
    arrMembersOf = CurrentUser.GetEx("memberOf")
    For Each strMembro in arrMembersOf
        mapear strMembro
        subGrupo strMembro
    Next
    
    '=========================================
    
    
    sub subgrupo(strcaminho)
    
    Set objGroup = GetObject("LDAP://" & strCaminho)
    objGroup.GetInfo
    
    arrSubMembro = objGroup.GetEx("memberOf")
    
    For Each strSubMember in arrSubMembro
       mapear strSubMember
    Next
    
    end sub
    
    '===========================================
    
    Sub DriveMapper(Drive)
    For i = 0 to oDrives.Count -1 Step 2
       if LCase(Drive) = LCase(oDrives.Item(i)) then
          WshNetwork.RemoveNetworkDrive Drive, true, true
       End if
    Next
    
    End sub
    
    '============================================
    
    Sub Mapear(strGrupoFIM)
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_1)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_2)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_3)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_4)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
     
    If InStr(UCASE(strGrupoFIM), UCASE(GG_5)) Then
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "I:", "\\SP1SDCMKHOUSE02\%USERNAME%"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_6)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_7)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_8)) Then
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_9)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_10)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_11)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    End sub


    Em consequencia desse erro, pelo menos acredito eu, todos os mapeamentos do arquivo estão sendo feito para todos usuarios. Mesmo que eles não tenham acesso.
    Porém ao tentar abrir a unidade mapeada da acesso negado.

    Algurém tem alguma idéia do que está acontecendo?

     

    obrigado!


    • Editado Fábio JrModerator terça-feira, 1 de outubro de 2013 13:50 Formatação do código
    terça-feira, 13 de julho de 2010 16:11

Respostas

  • Literalmente 2 anos depois hahaha

    Estou usando o mesmo VB para mapear as pasta na minha rede e tive problemas nessa linha também, mas resolvi ignorando-a com a seguinte linha no inicio do código On Error Resume Next e está funcionando normalmente.

    Ficando da seguinte forma:

    On Error Resume Next
    
    Const GG_1 = "cn=administrativo"
    Const GG_2 = "cn=comercial"
    Const GG_3 = "cn=coordenação"
    Const GG_4 = "cn=diretoria"
    Const GG_5 = "cn=financeiro"
    Const GG_6 = "cn=operação"
    Const GG_7 = "cn=planejamento"
    Const GG_8 = "cn=relatorios"
    Const GG_9 = "rh"
    Const GG_10 = "selecao"
    Const GG_11 = "TI"
    
    
    Set wshNetwork = CreateObject("WScript.Network")
    Set oDrives = WshNetwork.EnumNetworkDrives
    Set ADSysInfo = CreateObject("ADSystemInfo")
    'wscript.echo ADSysInfo.UserName
    Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
    DriveMapper "J:"
    DriveMapper "K:"
    DriveMapper "L:"
    DriveMapper "M:"
    DriveMapper "N:"
    DriveMapper "O:"
    DriveMapper "P:"
    DriveMapper "Q:"
    DriveMapper "R:"
    DriveMapper "T:"
    DriveMapper "U:"
    DriveMapper "V:"
    DriveMapper "W:"
    DriveMapper "X:"
    DriveMapper "Y:"
    DriveMapper "Z:"
    
     
    
    
    arrMembersOf = CurrentUser.GetEx("memberOf")
    For Each strMembro in arrMembersOf
        mapear strMembro
        subGrupo strMembro
    Next
    
    '=========================================
    
    
    sub subgrupo(strcaminho)
    
    Set objGroup = GetObject("LDAP://" & strCaminho)
    objGroup.GetInfo
    
    arrSubMembro = objGroup.GetEx("memberOf")
    
    For Each strSubMember in arrSubMembro
       mapear strSubMember
    Next
    
    end sub
    
    '===========================================
    
    Sub DriveMapper(Drive)
    For i = 0 to oDrives.Count -1 Step 2
       if LCase(Drive) = LCase(oDrives.Item(i)) then
          WshNetwork.RemoveNetworkDrive Drive, true, true
       End if
    Next
    
    End sub
    
    '============================================
    
    Sub Mapear(strGrupoFIM)
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_1)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_2)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_3)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_4)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
     
    If InStr(UCASE(strGrupoFIM), UCASE(GG_5)) Then
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "I:", "\\SP1SDCMKHOUSE02\%USERNAME%"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_6)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_7)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_8)) Then
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_9)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_10)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_11)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    End sub

    Abraço

    terça-feira, 1 de outubro de 2013 12:57

Todas as Respostas

  • Eae Pessoal, ninguém consegue me ajudar nessa questão?

     

    Vlw

    quinta-feira, 22 de julho de 2010 13:56
  • Literalmente 2 anos depois hahaha

    Estou usando o mesmo VB para mapear as pasta na minha rede e tive problemas nessa linha também, mas resolvi ignorando-a com a seguinte linha no inicio do código On Error Resume Next e está funcionando normalmente.

    Ficando da seguinte forma:

    On Error Resume Next
    
    Const GG_1 = "cn=administrativo"
    Const GG_2 = "cn=comercial"
    Const GG_3 = "cn=coordenação"
    Const GG_4 = "cn=diretoria"
    Const GG_5 = "cn=financeiro"
    Const GG_6 = "cn=operação"
    Const GG_7 = "cn=planejamento"
    Const GG_8 = "cn=relatorios"
    Const GG_9 = "rh"
    Const GG_10 = "selecao"
    Const GG_11 = "TI"
    
    
    Set wshNetwork = CreateObject("WScript.Network")
    Set oDrives = WshNetwork.EnumNetworkDrives
    Set ADSysInfo = CreateObject("ADSystemInfo")
    'wscript.echo ADSysInfo.UserName
    Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
    DriveMapper "J:"
    DriveMapper "K:"
    DriveMapper "L:"
    DriveMapper "M:"
    DriveMapper "N:"
    DriveMapper "O:"
    DriveMapper "P:"
    DriveMapper "Q:"
    DriveMapper "R:"
    DriveMapper "T:"
    DriveMapper "U:"
    DriveMapper "V:"
    DriveMapper "W:"
    DriveMapper "X:"
    DriveMapper "Y:"
    DriveMapper "Z:"
    
     
    
    
    arrMembersOf = CurrentUser.GetEx("memberOf")
    For Each strMembro in arrMembersOf
        mapear strMembro
        subGrupo strMembro
    Next
    
    '=========================================
    
    
    sub subgrupo(strcaminho)
    
    Set objGroup = GetObject("LDAP://" & strCaminho)
    objGroup.GetInfo
    
    arrSubMembro = objGroup.GetEx("memberOf")
    
    For Each strSubMember in arrSubMembro
       mapear strSubMember
    Next
    
    end sub
    
    '===========================================
    
    Sub DriveMapper(Drive)
    For i = 0 to oDrives.Count -1 Step 2
       if LCase(Drive) = LCase(oDrives.Item(i)) then
          WshNetwork.RemoveNetworkDrive Drive, true, true
       End if
    Next
    
    End sub
    
    '============================================
    
    Sub Mapear(strGrupoFIM)
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_1)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_2)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_3)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End if
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_4)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
     
    If InStr(UCASE(strGrupoFIM), UCASE(GG_5)) Then
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "I:", "\\SP1SDCMKHOUSE02\%USERNAME%"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_6)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_7)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_8)) Then
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_9)) Then
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_10)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO" 
       wshNetwork.MapNetworkDrive "V:", "\\SP1SDCMKHOUSE02\VBD"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
    End If
    
    If InStr(UCASE(strGrupoFIM), UCASE(GG_11)) Then
       wshNetwork.MapNetworkDrive "J:", "\\SP1SDCMKHOUSE02\RECRUTAMENTO"
       wshNetwork.MapNetworkDrive "K:", "\\SP1SDCMKHOUSE02\DIRETORIA"
       wshNetwork.MapNetworkDrive "L:", "\\SP1SDCMKHOUSE02\FINANCEIRO"
       wshNetwork.MapNetworkDrive "M:", "\\SP1SDCMKHOUSE02\RECEPCAO"
       wshNetwork.MapNetworkDrive "N:", "\\SP1SDCMKHOUSE02\RELATORIOS"
       wshNetwork.MapNetworkDrive "O:", "\\SP1SDCMKHOUSE02\TI"
       wshNetwork.MapNetworkDrive "P:", "\\SP1SDCMKHOUSE02\PUBLICO"
       wshNetwork.MapNetworkDrive "Q:", "\\SP1SDCMKHOUSE02\PLANEJAMENTO"
       wshNetwork.MapNetworkDrive "R:", "\\SP1SDCMKHOUSE02\RH"
       wshNetwork.MapNetworkDrive "T:", "\\SP1SDCMKHOUSE02\coordenacao"
       wshNetwork.MapNetworkDrive "U:", "\\SP1SDCMKHOUSE02\Comercial"
       wshNetwork.MapNetworkDrive "W:", "\\SP1SDCMKHOUSE02\CFIP"
       wshNetwork.MapNetworkDrive "X:", "\\SP1SDCMKHOUSE02\Producao"
       wshNetwork.MapNetworkDrive "Y:", "\\SP1SDCMKHOUSE02\shponto"
    End If
    End sub

    Abraço

    terça-feira, 1 de outubro de 2013 12:57