I have the script below which works fine.. however when the DOS prompt opens up I get two error: access denied messages. Now the script completely works for the groups posted and attaches the drives and printers correctly... where am I getting these errors from? Can I suppress them? Does it have to do with permissions... the users on the network only are Domain Admins and the respective security group. Option Explicit
'Declare variables
Dim objNetwork, objUser, CurrentUser
Dim strGroup
' Initialize Groups with Const
Const Accounting_Group = "cn=Accounting"
Const Private_Group = "cn=SM_Private"
Const Public_Group = "cn=SM_Public"
Const Technology_Group = "cn=SM_Technology"
Const Corporate_Group = "cn=SM_Corporate"
' Create objects and extract strGroup values
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
objNetwork.MapNetworkDrive "Q:", "\\server\Data"
objNetwork.MapNetworkDrive "I:", "\\server\Common"
strGroup = LCase(Join(CurrentUser.MemberOf))
' If logic testing strGroup for the values in Const groups
If InStr(strGroup, lcase(Corporate_Group)) Then
objNetwork.MapNetworkDrive "J:", "\\server\Corporate"
objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite"
objNetwork.SetDefaultPrinter "\\server\Executive-Suite"
ElseIf InStr(strGroup, lcase(Accounting_Group)) Then
objNetwork.MapNetworkDrive "K:", "\\server\Accounting"
objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02"
objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345"
objNetwork.SetDefaultPrinter "\\server\Dell1815dn02"
ElseIf InStr(strGroup, lcase(Public_Group)) Then
objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn"
objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150"
objNetwork.SetDefaultPrinter "\\server\1815dn(trade)"
ElseIf InStr(strGroup, lcase(Private_Group)) Then
objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)"
objNetwork.SetDefaultPrinter "\\server\1815dn(trade)"
ElseIf InStr(strGroup, lcase(Technology_Group)) Then
objNetwork.MapNetworkDrive "T:", "\\server\Tech"
objNetwork.AddWindowsPrinterConnection "\\server\Technology"
objNetwork.AddWindowsPrinterConnection "\\server\Dell3110"
objNetwork.SetDefaultPrinter "\\server\Technology"
End If
WScript.Quit
|