Die erweiterung des Drucker-Scriptes um die Gruppen-Abfragen läuft wie bei den Laufwerken:
' drucker.vbs - Einbindung der Netzwerkdrucker
' Author Christoph Goth
' -----------------------------------------------------------------'Option Explicit
Dim WSHNetwork, objUser, strUserName, strUserDomain, ObjGroupDict, WSHShell, objShell
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set objShell = CreateObject("Shell.Application")' Variablen Definieren und Wartezeit setzen
strUserName = ""
While strUserName = ""
WScript.Sleep 100
strUserName = WSHNetwork.UserName
Wend
strUserDomain = WSHNetwork.UserDomain
Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)Function MemberOf(ObjDict, strKey)
MemberOf = CBool(ObjGroupDict.Exists(strKey))
End Function' Benutzer-Gruppe Bestimmen
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' Drucker einbinden
If MemberOf(ObjGroupDict, "GRUPPE1") Then
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\DRUCKERFREIGABE"
End IfIf MemberOf(ObjGroupDict, "GRUPPE2") Then
WSHNetwork.AddWindowsPrinterConnection "\\SERVER\DRUCKERFREIGABE2"
End If' Ende des Windows Logon Scripts
Wscript.Quit