Computing.Net > Forums > Programming > Windows Logon Script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Windows Logon Script

Reply to Message Icon

Name: ksoliz
Date: February 25, 2009 at 15:57:32 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Windows Logon Script

Logon Scripts www.computing.net/answers/programming/logon-scripts/364.html

Logon Script www.computing.net/answers/programming/logon-script/3639.html

Windows Logon Utility www.computing.net/answers/programming/windows-logon-utility/6919.html