1、On Error Resume Next
 
Set objSysInfo = CreateObject("ADSystemInfo")
 
Set objNetwork = CreateObject("Wscript.Network")
 
strUserPath = "LDAP://" & objSysInfo.UserName
 
Set objUser = GetObject(strUserPath)
 
For Each strGroup in objUser.MemberOf
 
strGroupPath = "LDAP://" & strGroup
 
Set objGroup = GetObject(strGroupPath)
 
strGroupName = objGroup.CN
 
Select Case strGroupName
 
Case "Finance Users"
objNetwork.MapNetworkDrive "X:", " \\atl-fs-01\finance " ,true
 
Case "Human Resource Users"
objNetwork.MapNetworkDrive "X:", " \\atl-fs-01\hr "  ,true
 Case "Manufacturing Users"
objNetwork.MapNetworkDrive "X:", " \\atl-fs-01\manufacturing " ,true
 
Case "Shipping and Receiving Users"
objNetwork.MapNetworkDrive "X:", " \\atl-fs-01\shipping "  ,true
 
End  Select
 
Next
 
2、
On Error Resume Next
 
Dim objNetwork
Dim ObjFSO
Dim strUserPath
Dim strUserName
Dim oShell
Dim strDriveLetter1,strDriveLetter2,strDriveLetter3,strDriveLetter4,strDriveLetter5
Dim strRemotePath1,strRemotePath2,strRemotePath3,strRemotePath4,strRemotePath5
 
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
Set oShell= CreateObject("Shell.Application")
 
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
 
strDriveLetter1 = "P:"
strRemotePath1 = "
\\chafile01\DeptFolders "
 
strDriveLetter2 = "X:"
strRemotePath2 =  "
\\chafile01\public "
 
strDriveLetter3 = "U:"
strRemotePath3 =  "
\\chafile1\ "
 
strDriveLetter4 = "I:"
strRemotePath4 = "
\\chafile1\it$ "
 
strDriveLetter5 = "S:"
strRemotePath5 = "
\\chafile01\scan$ "
 
if(ObjFSO.DriveExists("P:"))then
objNetwork.RemoveNetworkDrive"P:",true
end if
 
if(ObjFSO.DriveExists("X:"))then
objNetwork.RemoveNetworkDrive"X:",true
end if
 
if(ObjFSO.DriveExists("U:"))then
objNetwork.RemoveNetworkDrive"U:",true
end if
 
if(ObjFSO.DriveExists("I:"))then
objNetwork.RemoveNetworkDrive"I:",true
end if
 
if(ObjFSO.DriveExists("S:"))then
objNetwork.RemoveNetworkDrive"S:",true
end if
 
For Each strGroup in objUser.MemberOf
   
 strGroupPath = "LDAP://" & strGroup
   
 Set objGroup = GetObject(strGroupPath)
  
  strGroupName = objGroup.CN
   
 Select Case strGroupName 
    
Case "CHA" 
 
strUserName = objNetwork.UserName
           
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3 & strUserName &"$"
'给每个用户建一个以 "AD用户名$" 命名的隐藏个人文件夹
           
oShell.NameSpace("U:\").Self.Name="个人网络文件夹"
 
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1 ,true
           
oShell.NameSpace("P:\").Self.Name="部门网络文件夹"
           
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2 ,true
           
 oShell.NameSpace("X:\").Self.Name="公共网络文件夹"
           
 objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5 ,true
           
 oShell.NameSpace("S:\").Self.Name="扫描件网络存储区"
         
 case "CHA-IT"          
           
 objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4 ,true
           
oShell.NameSpace("I:\").Self.Name="IT部网络文件夹"
End select
next
 
Set objSysInfo = nothing
Set objNetwork = nothing
Set ObjFSO = nothing
Set oShell = nothing
Set objUser = nothing
Set objGroup = nothing