Scripts to configure printers


As of Windows XP / Windows 2003 Server, Microsoft added a couple of vbs scripts to the %windir%\system32 directory. These scripts should be run from a command prompt (with CSCRIPT) and take arguments, so that they can be used as commands to configure and manage printers from a command prompt, or from batch files and other scripts. These scripts heavily rely on WMI, and it is very well possible they won't run on earlier Windows versions with more limited or no WMI support. Alternatives for older Windows systems are indicated below.

Publish Printers in Windows 2003 Server Active Directory

When a printer is shared in a Windows 2003 server, it is automatically published in Active Directory so that users can install it by browsing the directory. This also handles installation of drivers and takes care of elevating the user privilegues to allow the installation. Printers connected to the network by sharing on an older Windows system or so, the same can be accomplished with this script to publish printers in Active Directory.

script : Publish Printers in Active Directory

TCP/IP Printer Ports - prnport.vbs

script (command) to create TCP/IP Printer ports, Windows 2003/XP equivalent to this script to create TCP/IP Printer Ports.

install printer drivers - prndrvr.vbs

script (command) to install, remove or list printer drivers. Can be used in a script to install local printers, and thus replaces the rundll32 commands used in this script to install local printers.

Command Line Printer Control - prnmngr.vbs

script (command) to install, remove or list local printers, or add and remove printer connections to shared printers . Can be used in a script as a replacement for the rundll32 commands in this script to install local printers and as an alternative to the WSH Network object - addWindowsPrinter>COnnection method used in these scripts to connect to and install shared printers. There are also switches to delete (all) printers, specify printer ports, and set a default printer.

Printer Configuration - prncnfg.vbs

Use this script as a command to modify the configuration of an installed printer, e.g. change printer name, set printing times, edit properties such as description and location, ... prncnfg.vbs can apparently (judging from the argument list; not tested) be used to share a printer and set a share name, and could therefore be used as an alternative to this script to share printers on a server. As both scripts require the WMI of Windows XP / 2003, you'll still need rundll32 printui.dll with /z to share a printer on older systems (re. script to install and share printers)

Manage Print Jobs - prnjob.vbs

'Command' to pause, resume, cancel and list print jobs

PrintQueue Control - prnqctl.vbs

'Command' to control the print queue of a given printer : stop/resume printing of a document, remove documents, stop a printer, print a test page on a given printer, ...


Koen Noens
September 2005