Another Logon Script Example from 2008

Method 1 - Mixed Environment:
1. Edit the following script as appropriate
2. Then, save such script onto %SystemRoot%\sysvol\sysvol\<domain DNS name>\scripts
3. Assign the logon script to a user or group

Method 2 - Native Mode:
1. Create a new OU and move all users into that OU
2. Link a group policy to that OU
- Right-click the OU, Select Properties
- Under Group Policies tab, Click New or Edit to activate Group Policy Object Editor
- Navigate: User Configurations, Windows Settings, Scripts (Logon/logoff). Right-click Logon
- Click "show files" to open the folder that supposed to contain the scripts
- Copy the script file(s) into that folder so that those scripts will be replicated to other domain controllers
- Go back to Group Policy Object Editor and click Add to select the new script

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:",
"\\POESTRA_MAIN1\Users\" & wshNetwork.UserName

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

wshNetwork.MapNetworkDrive "g:",
"\\POESTRA_MAIN1\Engineering\"
wshNetwork.MapNetworkDrive "g:",
"\\POESTRA_MAIN1\Engineering\"
wshNetwork.MapNetworkDrive "g:",
"\\POESTRA_MAIN1\Engineering\"

wshNetwork.AddWindowsPrinterConnection
"\\POESTRA_MAIN1\EngLaser"
wshNetwork.AddWindowsPrinterConnection
"\\POESTRA_MAIN1\Plotter"
wshNetWork.SetDefaultPrinter
"\\POESTRA_MAIN1\EngLaser"


---------------------------------------------------------------------------------------------------------------------------------------
Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:",
"\\POESTRA_MAIN1\Users\" & wshNetwork.UserName

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

If InStr(strGroups, ENGINEERING_GROUP) Then

wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Engineering\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\EngLaser"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\Plotter"
wshNetWork.SetDefaultPrinter
"\\PrintServer\EngLaser"

ElseIf InStr(strGroups, FINANCE_GROUP) Then

wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Finance\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\FinLaser"
wshNetWork.SetDefaultPrinter
"\\PrintServer\FinLaser"

ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then

wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Human Resources\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\HrLaser"
wshNetWork.SetDefaultPrinter
"\\PrintServer\HrLaser"

End If
------------------------------------------------------
Implemented Logon Scripts:

---------------- logon.bat -----
echo off
cls
net use * /d /yes

net use i: "\\Poelstra-main1\ftp1" /y
net use g: "\\Poelstra-main1\users" /y
net use f: "\\Poelstra-main1\data" /y

\\POELSTRA-MAIN1\Clients\Setup\setup.exe /s "POELSTRA-MAIN1"

start \\Poelstra-main1\netlogon\printers.vbs
------------------------------------- -------------

-------------------- Printers.vbs ---------------------
on error resume next

Set objNetwork = CreateObject("WScript.Network")

objNetwork.AddWindowsPrinterConnection "\\POELSTRA-MAIN1\HP LaserJet 8000 Series PCL"
objNetwork.AddWindowsPrinterConnection "\\POELSTRA-MAIN1\HP Color LaserJet 3700 PCL 6"
objNetwork.AddWindowsPrinterConnection "\\POELSTRA-MAIN1\HP LaserJet 4350 PCL 6"

Wscript.Quit

Leave a Reply

Your email address will not be published. Required fields are marked *