Wednesday, August 02, 2006

 

Scripting Printer Creation

Windows XP and Windows 2003 include the following scripts in %windir%\system32 for CLI printer management

Prncnfg.vbs
Prndrvr.vbs
Prnjobs.vbs
Prnmngr.vbs
Prnport.vbs
Prnqctl.vbs

This is (IMO) much improved over the printui.dll hackery.

While there's some basic usage info out there on these scripts, I couldn't find anything that gives any good practical advice; aka "notes from the field."

Scenario: you have to create 50 printers on a print server. You have the following data: Name, Location, IP, Driver Name. Some additional assumptions: you only have Win2k/XP clients, you want to share each printer consistently, and default permissions (Everyone: Print) are sufficient.

There are four steps you need to do:
1. Create the port
2. Install the driver
3. Create the printer
4. Configure the printer

A sample script:
cscript C:\WINDOWS\system32\prnport.vbs -a -r IP_10.10.1.5 -h 10.10.1.5 -o raw -n 9100
cscript c:\WINDOWS\system32\prndrvr.vbs -a -m "HP LaserJet 4100 Series PCL" -v 3 -e "Windows NT x86"
cscript c:\windows\system32\prnmngr.vbs -a -p "Test1" -m "HP LaserJet 4100 Series PCL" -r IP_10.10.1.5
cscript C:\WINDOWS\system32\prncnfg.vbs -t -p "Test1" -l "Test Lab" -m "Comment" -h Test1 +shared +published +enablebidi

Line 1 creates the port named "IP_10.10.1.5" with the IP address 10.10.1.5, using RAW protocol on port 9100.

Line 2 installs the HP LJ 4100 PCL driver for Windows 2000/XP clients.

Line 3 creates the printer named "Test1" using the previously created port and driver.

Line 4 sets the location "Test Lab", comment "Comment", shares and publishes it as "Test1" and enables bi-directional support (if available).

The result is a shared printer identical to as if you had done it manually accepting the default settings.

I haven't yet written a script to loop through these commands with the input data for all 50 printers, but that will come shortly (and depending upon how well I do it I may or may not post it).

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?