Login Script
Page 1 of 1
Login Script
Some of you may find it useful
I find this alot more useful than creating multiple bat files or vb scripts
I find this alot more useful than creating multiple bat files or vb scripts
- Code:
Option Explicit
on error resume next
'--------Declares variables and allocates storage space with Dim------
Dim DriveLetter1, DriveLetter2, DriveLetter3, DriveLetter4
Dim DriveLetter5, DriveLetter6, DriveLetter7, DriveLetter8
Dim DriveLetter9, DriveLetter10
Dim RemotePath1, RemotePath2, RemotePath3, RemotePath4
Dim RemotePath5, RemotePath6, RemotePath7, RemotePath8
Dim RemotePath9, RemotePath10
Dim objNetwork, objUser, CurrentUser
Dim strGroup
Dim strList
Dim objSysinfo
Dim objPrinter
'-------- Initialise Groups with Const (cn names must be lowercase) --------
Const employees_Group = "cn=employees"
Const Admins_Group = "cn=admins"
Const upstairs_Group = "cn=upstairs"
Const downstairs_Group = "cn=downstairs"
Const Support_Group = "cn=support"
Const accountants_Group = "cn=accountants"
Const maintance_Group = "cn=maintance"
Const temp_Group = "cn=temp"
Const students_Group = "cn=all"
'-------- Create objects and extract values --------
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
Set objPrinter = CreateObject("WScript.Network")
Set objSysinfo = CreateObject("ADSystemInfo")
strList = objSysinfo.Computername
'-------- workaround for Join not supporting single group membership --------
If IsArray(CurrentUser.MemberOf) Then
strGroup = LCase(Join(CurrentUser.MemberOf))
Else
strGroup = lcase(CurrentUser.MemberOf)
End If
'-------- Contruct drive mapping --------
DriveLetter1 = "F:"
DriveLetter2 = "G:"
DriveLetter3 = "H:"
DriveLetter4 = "I:"
DriveLetter5 = "K:"
DriveLetter6 = "L:"
DriveLetter7 = "M:"
DriveLetter8 = "N:"
DriveLetter9 = "S:"
DriveLetter10 = "Y:"
DriveLetter11 = "Z:"
RemotePath1 = "\\server\shared"
RemotePath2 = "\\server\admins"
RemotePath3 = "\\server\upstairs"
RemotePath4 = "\\server\downstairs"
RemotePath5 = "\\server\support"
RemotePath6 = "\\server\accounting"
RemotePath7 = "\\server\hr"
RemotePath8 = "\\server\maintance"
RemotePath9 = "\\server\AR"
RemotePath10 = "\\server\temp"
RemotePath11 = "\\server\all"
'--------START Map Drives by Group Membership --------
'*******employees_Group*******
If InStr(strGroup, employees_Group ) Then
objNetwork.MapNetworkDrive DriveLetter1, RemotePath1
objNetwork.MapNetworkDrive DriveLetter3, RemotePath3
objNetwork.MapNetworkDrive DriveLetter4, RemotePath4
objNetwork.MapNetworkDrive DriveLetter5, RemotePath5
objNetwork.MapNetworkDrive DriveLetter8, RemotePath8
objNetwork.MapNetworkDrive DriveLetter10, RemotePath10
End If
'*******Admins_Group********
If InStr(strGroup, admins_Group ) Then
objNetwork.MapNetworkDrive DriveLetter2, RemotePath2
objNetwork.MapNetworkDrive DriveLetter6, RemotePath6
objNetwork.MapNetworkDrive DriveLetter7, RemotePath7
objNetwork.MapNetworkDrive DriveLetter9, RemotePath9
objNetwork.MapNetworkDrive DriveLetter11, RemotePath11
End If
'*******support_Group*******
If InStr(strGroup, support_Group ) Then
objNetwork.MapNetworkDrive DriveLetter5, RemotePath5
End If
'*******accountants_Group*******
If InStr(strGroup, accountants_Group ) Then
objNetwork.MapNetworkDrive DriveLetter6, RemotePath6
objNetwork.MapNetworkDrive DriveLetter7, RemotePath7
objNetwork.MapNetworkDrive DriveLetter9, RemotePath9
objNetwork.MapNetworkDrive DriveLetter10, RemotePath10
End If
'*******maintance_Group*******
If InStr(strGroup, maintance_Group ) Then
objNetwork.MapNetworkDrive DriveLetter8, RemotePath8
End If
'*******temp_Group*******
If InStr(strGroup, temp_Group ) Then
objNetwork.MapNetworkDrive DriveLetter10, RemotePath10
End If
'*******students_Group*******
If InStr(strGroup, students_Group ) Then
objNetwork.MapNetworkDrive DriveLetter11, RemotePath11
End If
'--------END Map Drives by Group Membership --------
'-------- Assign Printer by Group Membership --------
If InStr(strGroup, employees_Group ) Then
objPrinter.AddWindowsPrinterConnection "\\server\c3d-hp2230"
objPrinter.AddWindowsPrinterConnection "\\server\c3c-hp2200"
objPrinter.AddWindowsPrinterConnection "\\server\T5A-HP1100"
objPrinter.AddWindowsPrinterConnection "\\server\library-hp1100"
objPrinter.AddWindowsPrinterConnection "\\server\C2G-HP2230"
End If
'-------- Assign Printer by OU's --------
'If instr(strList, "OU=C3D") then
'objPrinter.AddWindowsPrinterConnection "\\admin-server2\c3d-hp2230"
'objPrinter.SetDefaultPrinter "\\admin-server2\c3d-hp2230"
'ElseIf instr(strList, "OU=C3C") then
'objPrinter.AddWindowsPrinterConnection "\\admin-server2\c3c-hp2200"
'objPrinter.SetDefaultPrinter "\\admin-server2\c3c-hp2200"
'ElseIf instr(strList, "OU=T5A") then
'objPrinter.AddWindowsPrinterConnection "\\admin-server2\T5A-HP1100"
'objPrinter.SetDefaultPrinter "\\admin-server2\T5A-HP1100"
'ElseIf instr(strList, "OU=C2G") then
'objPrinter.AddWindowsPrinterConnection "\\admin-server2\C2G-HP2230"
'objPrinter.SetDefaultPrinter "\\admin-server2\C2G-HP2230"
'ElseIf instr(strList, "OU=Library") then
'objPrinter.AddWindowsPrinterConnection "\\admin-server2\library-hp1100"
'objPrinter.SetDefaultPrinter "\\admin-server2\library-hp1100"
'End If
WScript.Quit
andry- Moderator
- Posts : 467
Join date : 2010-05-07
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|