Basic Printer Script for Deploying Network Printers

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

'==========================================================================
'
' 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:



Article ID: 242
Last updated: 16 Jan, 2014
Revision: 5
Third Party Products -> Windows Server -> Installation and Software -> Basic Printer Script for Deploying Network Printers
https://kb.stonegroup.co.uk/index.php?View=entry&EntryID=242