Try this VBS script.
It features a delay at the start to check the user is properly logged on, and will map drives according to group memberships in AD. Been using it on our network for over a year now with no problems. I can't take credit for it, I found it on a messageboard somewhere ages ago.
Code:
Option Explicit ' Force explicit declarations
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
'
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
WScript.Sleep 100 ' 1/10 th of a second
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
If MemberOf(ObjGroupDict, "All Students") Then
call map("P:", "\\SERVER\share")
end if
If MemberOf(ObjGroupDict, "All Staff") Then
call map("O:", "\\server\share")
End If
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
sub map( drive, share )
on error resume next
WSHNetwork.removenetworkdrive drive, true
WSHNetwork.mapnetworkdrive drive, share
end sub If you don't want to use the advanced features of reading the group memberships, you can remove those bits, just retaining the drive mapping and delay at the start.
Mike.