# How do i make this login script work?



## nvisibl (Feb 11, 2010)

i've created the following script using active directory groups to assign mapped drives and network printers

i've put it into the netlogon share on my single domain controller

to test i've put the path to the login script within my own account properties under user profile/login script as follows:
c:\windows\sysvol\sysvol\domainname.com\scripts\login.vbs

i'm in the IT group so when logging in should have the Z: and M: drives mapped as well as a XEROX printer

the login script doesn't run at all during login and i don't know why

can you help???

is the above path okay within my own user account properties???
should i do anything additional to active the login script?

script below.....












Const IT = "cn=IT"
Const FINANCE = "cn=finance"
Const Catering = "cn=catering"
Const Retail = "cn=retail"
Const Customerservices = "cn=customer services"
Const technicalmaintenance = "cn=Technical Maintenance"
Const HR = "cn=HR"
Const Health&Safety = "cn=Health & Safety"
Const Marketing = "cn=Marketing"
Const Executive = "cn=Executive"
Const Rangers = "cn=Rangers"
Const Events = "cn=Events"
Const Winteroperations = "cn=Winter operations"
Const skihire = "cn=Ski Hire"





Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "z:",
"\\cairnserve1\" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" &
ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, IT) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\IT"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\xerox_marketing"


ElseIf InStr(strGroups, FINANCE) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\Finance\"
wshNetwork.MapNetworkDrive "s:",
"\\cairnserve2\sage\"
wshNetwork.MapNetworkDrive "p:",
"\\cairnserve3\payroll\"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_accounts_hr"
wshNetWork.SetDefaultPrinter
"\\cairnserve1\accountsprinter"

ElseIf InStr(strGroups, HR) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\hr"
wshNetwork.MapNetworkDrive "v:",
"\\cairnserve1\hr"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_accounts_hr"
wshNetWork.SetDefaultPrinter
"\\cairnserve1\accountsprinter"

ElseIf InStr(strGroups, catering) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\catering"
wshNetwork.MapNetworkDrive "l:",
"\\cairnserve3\labellogicdata"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_catering"


ElseIf InStr(strGroups, retail) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\retail"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_retail"

ElseIf InStr(strGroups, customer services) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\customerservices"
wshNetwork.MapNetworkDrive "p:",
"\\ticketserver\provenue"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_customer_services"
wshNetWork.SetDefaultPrinter
"\\cairnbuscomms1\hp2300"

ElseIf InStr(strGroups, technical maintenance) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\techmain"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_maintenance_hs"


ElseIf InStr(strGroups, health & safety) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\Health&Safety"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_maintenance_hs"

ElseIf InStr(strGroups, marketing) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\Health&Safety"
wshNetwork.MapNetworkDrive "i:",
"\\cairnserve3\images"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_marketing"

ElseIf InStr(strGroups, rangers) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\rangers"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_marketing"


ElseIf InStr(strGroups, events) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\events"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_marketing"


ElseIf InStr(strGroups, winter operations) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\winteroperations"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_maintenance_hs"


ElseIf InStr(strGroups, ski hire) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\skihire"
wshNetwork.AddWindowsPrinterConnection
"\\cairnserve1\xerox_ski_hire"


ElseIf InStr(strGroups, executive) Then

wshNetwork.MapNetworkDrive "m:",
"\\cairnserve1\executive"


End If


----------



## aasimenator (Dec 21, 2008)

you can try through group policy management console

http://www.computerperformance.co.uk/Logon/logon_script_assign.htm


----------



## nvisibl (Feb 11, 2010)

thank you
gave a it a try, and added the above vbs file script but it still doesn't work, or show up during account login


----------



## Patrickv (Feb 10, 2010)

I had problems with window 7 because of the computer protection software built in, i don't remeber the name of the program, but it caused the running of the map drive script not map correctly. That could be one of your problems.



> to test i've put the path to the login script within my own account properties under user profile/login script as follows:
> c:\windows\sysvol\sysvol\domainname.com\scripts\login.vbs


well you can make this script run under each account but i would recommend this: \\server\NETLOGIN\login.vbs not this: c:\windows\sysvol\sysvol\domainname.com\scripts\login.vbs because you are pointing to a local path which my not be on the client desktop, it is recomended that it is always use remote paths when setup the server on a newtork. Another idea is appy this script to a Group Policy


----------



## nvisibl (Feb 11, 2010)

thanks for your responses

turns out it was a permissions thing where the users didn't have read/execute permissions on the file

and in setting it in their account profile i just entered the filename logon.vbs without any path

works now


----------



## syedmdsiraj5050 (Feb 8, 2010)

Hi

I have a suggestion..
I had the same issue... i put logon.vbs earlier for mapping network drives and to open some ie windows while logging on...

But then i tried using batch files, it working perfectly..

I suggest using the old way, logon.bat

Regards

Syed Mohammed Sirajuddin SA


----------

