
Código: Selecionar todos
' Script de mapeamento de Unidades
' Retirado do Fórum itbr.org
' www.itbr.org/forum
' Edite somente no campo informado no final do Script
' Para mais mapeamentos basta adicionar mais linhas com respectivas unidades e caminhos UNC
on error resume next
set network = CreateObject("WScript.Network")
set shell = CreateObject("WScript.Shell")
domainname = network.UserDomain
username = network.UserName
computername = network.ComputerName
set user = GetObject("WinNT://" & domainname & "/" & username)
redim groups(0)
For Each groupobj in user.Groups
redim preserve groups(ubound(groups) + 1)
groups(ubound(groups)) = groupobj.name
Next
Function getNextLetter()
set drivelist = network.enumNetworkDrives()
letters = "ZYXWVUTSRQPONMLKJIHGFE"
For i = 1 To 22
driveexists = false
drive = Mid(letters,i,1) & ":"
For j = 0 To drivelist.count() -1 Step 2
If drivelist.item(j) = drive Then
driveexists = true
End If
Next
If driveexists = false Then
getNextLetter = drive
Exit Function
End If
Next
End Function
Function mapDrive(letter,path)
If letter = "*:" or letter = "" Then
mapDrive = network.MapNetworkDrive(getNextLetter,path)
else
mapDrive = network.MapNetworkDrive(letter,path)
End If
End Function
Function mapIfUser(user,letter, path)
If UCase(user) = UCase(username) Then
mapDrive letter, path
End If
End Function
Function mapIfComputer(computer,letter, path)
If UCase(computer) = UCase(computername) Then
mapDrive letter, path
End If
End Function
Function mapIfMember(group, letter, path)
For Each i in groups
If UCase(i) = UCase(group) Then
mapDrive letter, path
Exit Function
End If
Next
End Function
' EDITE A PARTIR DESTE PONTO CONFORME SUAS NECESSIDADES
' Formato: mapIfMember "GRUPO DO USUARIO", "LETRA:", "\\HOSTNAMEOUENDEREÇOIP\SHARE"
mapIfMember "Grupo_TI", "M:", "\\SEUSERVIDORDEARQUIVOS\UTILITARIOS"
mapIfMember "Grupo_Financeiro", "Q:", "\\SEUSERVIDORDEARQUIVOS\FINANCEIRO"
mapIfMember "Grupo_RH", "X:", "\\SEUSERVIDORDEARQUIVOS\RECURSOSHUMANOS"