Logon script to map printers to people in specified OU's

Posted on 2004-11-02
Last Modified: 2010-05-02
Any help or suggestions will be much appriciated because i am new to scripting.  Here is my problem.  I have 25 XP machines in an OU called StandaloneXP.  I have a group policy applied to the computers in this OU so that all users who log on to these machines will have the policy applied to them.  Users who log into these machines belong to different departments - I have all my users in seperate OU's by department.  I want to create a VBScript so that when a user logs onto one of the XPMachines it will map certain printers by which department OU the user is in.  

For instance:

When user in finance department(finance OU) logs on to XPMAchine they need to have 8 finance printers mapped when they logon.

When user in hr department (HumanResources OU) logs on they need to have 4 HR printers mapped etc etc etc....

****Now i know i can add the script to each Department OU and script the printers like that.  But i run a mixed envirnoment where some users have 2000/xp client machines and others run thin client  - citrix.  Some users use both so i want to keep the script contained to the StandAloneXP OU where all the Xp computers are.  

I am new to scripting so I am pasting a copy of the script i wrote to map drives and printers.  I would like to add or change this around so i can do what i have explained above.  This script basically only maps the finance printers for everyone that logs into the XPMachines.  

Dim objNet
Set objNet = CreateObject("Wscript.Network")
' Forces script to skip errors (rem below line to see errors)
on error resume next

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
' all drives to be removed here are set here.
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.RemoveNetworkDrive "Q:"
WshNetwork.RemoveNetworkDrive "F:"
'all drives to be mapped are set here.
objNet.MapNetworkDrive "H:", "\\FS01\MIS111"
objNet.MapNetworkDrive "Q:", "\\FC01\ETIME"
objNet.MapNetworkDrive "F:", "\\SOH\SYS"

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE_4", "FINANCE_4"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE_9", "FINANCE_9"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE-2", "FINANCE_2"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE--2", "FINANCE_22"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE-3", "FINANCE_3"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE-6", "FINANCE_6"
net.AddWindowsPrinterConnection "\\LIHFS01\FINANCE-8", "FINANCE_8"

Question by:GPEARL383
    1 Comment
    LVL 76

    Accepted Solution

    Take a look at this previous EE question that addresses the same issue.

    Pay attention to the post from stablerm Date: 02/02/2004 11:49AM EST

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now