Stone Computers Knowledgebase

Basic Printer Script for Deploying Network Printers

Article ID: 242
Last updated: 16 Jan, 2014
Article ID: 242
Last updated: 16 Jan, 2014
Revision: 5
Views: 1771
Posted: 25 Nov, 2013
by Jason White
Updated: 16 Jan, 2014
by Andrew Sharrad

Basic 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.

Change the names of the printers (for example \\server\printer01 )) to those on your network server.

This script is a VB Script and can be called from a batch file using using cscript - i.e. cscript RemoveNetPrinters.vbs

Known Limitations

  • This script cannot be run as part of a computer startup script.
  • This script does not detect user active directory containers (OUs) and so you will need to use one script per group of deployed printers, or use a more complex script.
  • The first printer to be deployed and the default printer should be the same, to ensure reliability of selecting the default printer.

'==========================================================================
'
' NAME: RemoveNetPrinters.vbs
' COMMENT: Removes and add all net printers (XP Only)
'
'==========================================================================
ON ERROR RESUME NEXT
Set wshNet = CreateObject("WScript.Network")
Set wshPrn = wshNet.EnumPrinterConnections
For x = 0 To wshPrn.Count - 1 Step 2
If Left(wshPrn.Item(x+1),2) = "\\" Then wshNet.RemovePrinterConnection wshPrn.Item(x+1),True,True
Next

wshnet.AddWindowsPrinterConnection "\\server\printer01"
wshnet.AddWindowsPrinterConnection "\\server\printer02"
wshnet.SetDefaultPrinter "\\server\printer01"
'==========================================================================

Note: Credits for this script goes to the Spiceworks community.

Applies to:

  • Windows workstations on a domain network

This article was:  
Article ID: 242
Last updated: 16 Jan, 2014
Revision: 5
Views: 1771
Posted: 25 Nov, 2013 by Jason White
Updated: 16 Jan, 2014 by Andrew Sharrad
Attached files

Also read