This is my final Logon Script, I ran though my apex of IT some years ago, i'm a bit old school, so all my scrips start off from batch files, in the end, the final product works very well imo.
But for those interested in how i've done it, mixed and matched it, and etc, you may use this script.
___________________________________________________________
On Error Resume Next
Dim objNetwork, objUser, CurrentUser, objsysinfo, objapp
Dim strGroup, strlist, wshell
Dim objFSO, objFILE, objShell
Const Administrators = "cn=administrators"
Const Gymcode = "cn=gymcode"
Const Waseya_House = "cn=waseya"
Const Medical_Report = "cn=mreport"
Const Inventory = "cn=inventory"
Const IFormula = "cn=iformula"
Const Vaxin = "cn=vaxin"
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
set objFSO=CreateObject("Scripting.FileSystemObject")
set objShell=CreateObject("Wscript.Shell")
set objsysinfo = Createobject("ADSysteminfo")
set objapp = Createobject("WScript.shell")
set wshell = Createobject("WScript.shell")
strlist = objSysinfo.Computername
strWelcomeMsg="Welcome to the Health Centre secure network."
strHelpMsg="Contact the technician for further assistance."
iErrorTimeout=10
blnShowError=True
If isarray(CurrentUser.Memberof) then
strgroup = LCase(Join(CurrentUser.memberof))
Else
strgroup = LCase(CurrentUser.Memberof)
End If
' ******************************** GENERAL MAPPING ********************************
objNetwork.MapNetworkDrive "P:", "\\server\public"
objNetwork.MapNetworkDrive "X:", "\\server\" & objNetwork.UserName & "$"
objNetwork.MapNetworkDrive "I:", "\\server\installer$"
' **************************** GROUP MEMBERSHIP MAPPING ****************************
If InStr(strGroup, Administrators) Then
objNetwork.MapNetworkDrive "W:", "\\server\adm$"
objNetwork.MapNetworkDrive "Z:", "\\server\installer$\Tools\Health Centre Network\Health Centre Network"
End If
' **********************************************************************************
If InStr(strGroup, Gymcode) Then
objNetwork.MapNetworkDrive "V:", "\\server\gymcode$"
End If
' **********************************************************************************
If InStr(strGroup, Waseya_House) Then
objNetwork.MapNetworkDrive "S:", "\\server\waseya$"
End If
' **********************************************************************************
If InStr(strGroup, Medical_Report) Then
objNetwork.MapNetworkDrive "R:", "\\server\mreport$"
End If
' **********************************************************************************
If InStr(strGroup, Inventory) Then
objNetwork.MapNetworkDrive "T:", "\\server\inventory$"
End If
' **********************************************************************************
If InStr(strGroup, IFormula) Then
objNetwork.MapNetworkDrive "U:", "\\server\iformula$"
End If
' **********************************************************************************
If InStr(strGroup, Vaxin) Then
objNetwork.MapNetworkDrive "Q:", "\\server\apps"
End If
' ******************************** SUMMARY MESSAGE ********************************
iDisplayTimeout=8
strMsg=""
strMsg=strMsg & strWelcomeMsg & VbCrLf
strMsg=strMsg & vbcrlf
strMsg=strMsg & vbcrlf
Set objDrives = objNetwork.EnumNetworkDrives
strMsg=strMsg & "Network drive mappings:" & vbcrlf
For i = 0 to objDrives.Count - 1 Step 2
strMsg=strMsg & "Drive " & objDrives.Item(i) & "=" & objDrives.Item(i+1) & vbcrlf
Next
strMsg=strMsg & vbcrlf
If strMsg<>"" Then objShell.Popup strMsg,iDisplayTimeout,"Network Drive Summary",vbOKOnly+vbInformation
' **********************************************************************************
Set objDrives = NOTHING
Set objNetwork = NOTHING
Set objUser = NOTHING
Set CurrentUser = NOTHING
set objFSO = NOTHING
set objShell = NOTHING
set objsysinfo = NOTHING
set objapp = NOTHING
set wshell = NOTHING
wscript.end
But for those interested in how i've done it, mixed and matched it, and etc, you may use this script.
___________________________________________________________
On Error Resume Next
Dim objNetwork, objUser, CurrentUser, objsysinfo, objapp
Dim strGroup, strlist, wshell
Dim objFSO, objFILE, objShell
Const Administrators = "cn=administrators"
Const Gymcode = "cn=gymcode"
Const Waseya_House = "cn=waseya"
Const Medical_Report = "cn=mreport"
Const Inventory = "cn=inventory"
Const IFormula = "cn=iformula"
Const Vaxin = "cn=vaxin"
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
set objFSO=CreateObject("Scripting.FileSystemObject")
set objShell=CreateObject("Wscript.Shell")
set objsysinfo = Createobject("ADSysteminfo")
set objapp = Createobject("WScript.shell")
set wshell = Createobject("WScript.shell")
strlist = objSysinfo.Computername
strWelcomeMsg="Welcome to the Health Centre secure network."
strHelpMsg="Contact the technician for further assistance."
iErrorTimeout=10
blnShowError=True
If isarray(CurrentUser.Memberof) then
strgroup = LCase(Join(CurrentUser.memberof))
Else
strgroup = LCase(CurrentUser.Memberof)
End If
' ******************************** GENERAL MAPPING ********************************
objNetwork.MapNetworkDrive "P:", "\\server\public"
objNetwork.MapNetworkDrive "X:", "\\server\" & objNetwork.UserName & "$"
objNetwork.MapNetworkDrive "I:", "\\server\installer$"
' **************************** GROUP MEMBERSHIP MAPPING ****************************
If InStr(strGroup, Administrators) Then
objNetwork.MapNetworkDrive "W:", "\\server\adm$"
objNetwork.MapNetworkDrive "Z:", "\\server\installer$\Tools\Health Centre Network\Health Centre Network"
End If
' **********************************************************************************
If InStr(strGroup, Gymcode) Then
objNetwork.MapNetworkDrive "V:", "\\server\gymcode$"
End If
' **********************************************************************************
If InStr(strGroup, Waseya_House) Then
objNetwork.MapNetworkDrive "S:", "\\server\waseya$"
End If
' **********************************************************************************
If InStr(strGroup, Medical_Report) Then
objNetwork.MapNetworkDrive "R:", "\\server\mreport$"
End If
' **********************************************************************************
If InStr(strGroup, Inventory) Then
objNetwork.MapNetworkDrive "T:", "\\server\inventory$"
End If
' **********************************************************************************
If InStr(strGroup, IFormula) Then
objNetwork.MapNetworkDrive "U:", "\\server\iformula$"
End If
' **********************************************************************************
If InStr(strGroup, Vaxin) Then
objNetwork.MapNetworkDrive "Q:", "\\server\apps"
End If
' ******************************** SUMMARY MESSAGE ********************************
iDisplayTimeout=8
strMsg=""
strMsg=strMsg & strWelcomeMsg & VbCrLf
strMsg=strMsg & vbcrlf
strMsg=strMsg & vbcrlf
Set objDrives = objNetwork.EnumNetworkDrives
strMsg=strMsg & "Network drive mappings:" & vbcrlf
For i = 0 to objDrives.Count - 1 Step 2
strMsg=strMsg & "Drive " & objDrives.Item(i) & "=" & objDrives.Item(i+1) & vbcrlf
Next
strMsg=strMsg & vbcrlf
If strMsg<>"" Then objShell.Popup strMsg,iDisplayTimeout,"Network Drive Summary",vbOKOnly+vbInformation
' **********************************************************************************
Set objDrives = NOTHING
Set objNetwork = NOTHING
Set objUser = NOTHING
Set CurrentUser = NOTHING
set objFSO = NOTHING
set objShell = NOTHING
set objsysinfo = NOTHING
set objapp = NOTHING
set wshell = NOTHING
wscript.end