Stone Computers Knowledgebase

Advanced Printer Script for Deploying Network Printers

Article ID: 271
Last updated: 17 Jan, 2014
Article ID: 271
Last updated: 17 Jan, 2014
Revision: 9
Views: 3093
Posted: 16 Jan, 2014
by Andrew Sharrad
Updated: 17 Jan, 2014
by Andrew Sharrad

Advanced Printer Script

Use the script below as part of a group policy user login script. It will delete all local printers and apply the network printers specified. Known to work on Windows XP, Windows Vista and Windows 7.

The advanced printer script deploys printers based on the Active Directory container, or OU name.

Printers by Computer

The script "printers_by_computer_OU.vbs" will look at the computer's active directory location; this is the recommended script to use. When a user logs in and this script is applied, the printers will be set based on the machines location. This is likely to be the most convenient to the user.

Printers by User

The script "printers_by_user_OU.vbs" will look at the user's active directory location. When a user logs in and this script is applied, the printers will always be the same, no matter where the user logs in. This gives the user consistent printer settings; however if they change location the printers offered may not be convenient.

Note that either script may increase login times as printer connections are made as the user logs in. Login times may be additionally increased for the first time the computer downloads and installs the appropriate printer driver from the server.

On Either Script

  • Change the names of the printers (for example \\servername\printer01 )) to those on your network server.
  • Change the names of the OUs, for example "All Printers"
  • Copy sections of the script starting with "ElseIf" to the next "ElseIf" to add more groups of printers - for example:

ElseIf strOU = "Year4" Then
        For i = 1 to oPrinters.Count - 1 Step 2
               WshNetwork.RemovePrinterConnection oPrinters.Item(i)
        Next
    objNetwork.AddWindowsPrinterConnection "\\servername\classroom4_printer"
    objNetwork.SetDefaultPrinter "\\servername\classroom4_printer"

  • Call either script from a batch file as part of a user login script.

Known Limitations

  • This script should not be used as part of a computer startup script.
  • It is not recommended to use both printer scripts on the same tree of users and computers at the same time.
  • The first printer to be deployed and the default printer should be the same, to ensure reliability of selecting the default printer.

Tip: If you wish to apply the group policy containing this script to machines of a certain operating system, use group policy WMI filters. For example, this may help you deploy printers to Windows XP machines on a network where you already have a working printer deployment method for Windows 7 machines. Of course, its better if possible to segregate your Windows 7 and Windows XP machines into different OUs in Active directory, but this isn't always possible. For more information on WMI filters see this link. As an example, a Windows XP WMI filter is select * from Win32_OperatingSystem where (Version like "5.1%" or Version like "5.2%") and ProductType = "1"

Applies to:

  • Windows workstations on a domain network

This article was:  
Article ID: 271
Last updated: 17 Jan, 2014
Revision: 9
Views: 3093
Posted: 16 Jan, 2014 by Andrew Sharrad
Updated: 17 Jan, 2014 by Andrew Sharrad
Attached files

Also read