Among Windows XP’s many new command line tools are six print utilities written in VBScript. These clever little scripts, listed in Table A, make it easy for you to quickly query and manage printers as well as perform many other common printing tasks. Since Microsoft hasn’t really provided command line tools (let alone printer utilities) written in VBScript with an operating system before, they’re easy to overlook. However, these utilities add some really useful features to Windows XP. I’ll introduce you to Windows XP’s six command line print utilities and explain why they’re an important addition to the operating system. As I do, I’ll offer some example situations of when these scripts might come in handy.
Table A
|
Windows XP’s command line printing utilities
Why use the command line?
The first thing that probably came to mind when you read the introduction is, “Why would you need command line print utilities in Windows XP? Can’t you perform all print tasks from Windows XP’s GUI-based Printer and Faxes tool?” Well, the answer to the second question is “Yes.” You can perform all printing tasks from Windows XP’s GUI-based Printer and Faxes tool. However, the answer to the first question is more complex. There are several reasons why Microsoft decided to provide command line print utilities with Windows XP.
The first reason is that these scripts really showcase some of the powerful features provided by Windows Script Host and Windows Management Instrumentation (WMI). Another reason is that because these command line print tools are written in VBScript, they add a whole new dimension to Windows XP’s scripting capabilities. Crafty scripting wizards can use them as models for exercising more advanced control of an output mechanism from within Windows Script Host-based scripts. The third reason is convenience, since these command line printing utilities provide quick and direct access to very specific printing tasks that are within the Windows XP GUI but that may be buried deep within a dialog box somewhere. And, best of all, these command line printing utilities allow you to remotely access and control network printers.
Windows Management Instrumentation
Windows Management Instrumentation, or WMI for short, is the Microsoft implementation of Web-Based Enterprise Management (WBEM), an industry initiative to establish standards for accessing and sharing management information over an enterprise network. The integration of WMI with Windows Script Host adds a very powerful instrument to the operating system, where it’s easily accessible.
Now, when you combine all these reasons and focus them on a specific task, you can really grasp the power and benefits that having command line access to print utilities brings to the table. For example, suppose you have a printer that is so heavily used that it frequently needs to have its ink cartridges replaced. Rather than shutting down the printer and alerting everyone that you’ll be replacing the ink cartridges, you could create and run a customized script that temporarily puts the printer in offline mode, during which users could still send print jobs to the print queue. When you’re done replacing the ink cartridges, you could run another customized script that puts the printer back online, at which time printing will continue as though there had been no interruption.
Running the printer utilities
Before we actually begin examining these printer utilities, let’s take a moment to look at how you run them. It’s important to understand that running the printer utilities can be a bit tricky due to the terse rules governing command line scripts.
To begin with, the six printer utilities are located in the systemroot\system32 folder, which on most Windows XP installations is C:\Windows\System32. Now, even though this folder is listed in the path by default, you must actually change to this folder in order to run the utilities. And, since these utilities are designed to run from the command line, you’ll need to launch them from a command prompt, and you must run them using Windows Script Host’s command line script host (Cscript.exe).
The basic syntax for running these command line scripts is:
Cscript utility.vbs parameters
Furthermore, if any of the information contained in the parameters section contains spaces, such as My Computer, you must enclose that text in quotation marks.
Prncnfg.vbs
The Prncnfg.vbs script provides a printer configuration utility that lets you display and change printer configuration information. You can also use it to rename a printer.
This printer configuration utility comes in handy in a number of different situations. For example, suppose you want to build an inventory database of all the printers on your network. You could sue the Prncnfg.vbs script’s ability to display printer configuration information. This is the command syntax:
cscript prncnfg.vbs -g [-s RemoteComputer] -p PrinterName [-u UserName -w Password]
You could then use the redirection symbols on the actual command line to compile the output into a text file that you could later import into a database or a spreadsheet. The parameters used on this command line are detailed in Table B.
Table B
|
Parameters to configure the Prncnfg.vbs script to display printer configuration information
Prndrvr.vbs
The Prndrvr.vbs script provides a printer driver utility that lets you list and examine printer drivers. You can also use it to delete and add printer drivers.
If you’re troubleshooting a printer problem that could possibly be linked to outdated or missing printer drivers, you can use the Prndrvr.vbs script to quickly build a list of all the files that make up the printer driver, which you could then use for comparison. To do so, use this command syntax:
cscript prndrvr.vbs-l [-sRemoteComputer] [-uUserName-wPassword]
The parameters used on this command line are detailed in Table C.
Table C
|
Parameters to configure the Prndrvr.vbs script to list all the printer driver files
Prnjobs.vbs
The Prnjobs.vbs script provides a print job monitoring utility that lets you pause, resume, cancel, and list print jobs. For example, suppose there are a number of network printers to which you can print, and you have an urgent print job. You can use the Prnjobs.vbs script to browse around for the least busy printer. To do so, you’d use this command syntax:
cscript prnjobs -l [-s RemoteComputer] [-p PrinterName] [-u UserName -w Password]
The parameters used on this command line are detailed in Table D.
Table D
|
Parameters to configure the Prnjobs.vbs script to list all jobs in the print queue
Prnmngr.vbs
The Prnmngr.vbs script provides a printer management utility that lets you add, delete, and list printer connections. You can also use it to set and display the default printer.
The Prnmngr.vbs script comes in handy if you need to quickly add a new network printer connection to a group of computers. You could create a script or a batch file that automates the installation procedure via the Prnmngr.vbs script. To do so, you’d use the command syntax:
cscript prnmngr.vbs -a -p PrinterName [-s RemoteComputer] -m DriverName -r PortName [-u UserName -w Password]
The parameters used on this command line are detailed in Table E.
Table E
|
Parameters to configure the Prnmngr.vbs script to add a new printer
Prnport.vbs
The Prnport.vbs script provides a printer port management utility that lets you create, delete, and list standard TCP/IP printer ports. It also allows you to display and change port configuration.
For example, suppose you needed to create a standard TCP/IP printer port. You could go to the Printers and Faxes tool and run the Add Standard TCP/IP Printer Port Wizard, but that would require a number of steps. If you already have all the settings in hand, you can perform the operation much more quickly by using the Prnport.vbs script with this syntax:
cscript prnport.vbs -a -r PortName [-s RemoteComputer] -h IPAddress [-u UserName -w Password] [-o {raw -n PortNumber | lpr}] [-q QueueName] [-m{e | d}] [-i IndexName] [-y CommunityName] [-2{e | d}]
The parameters used on this command line are detailed in Table F.
Table F
|
Parameters to use the Prnport.vbs script to create a standard TCP/IP printer port
Prnqctl.vbs
The Prnqctl.vbs script provides a printer queue management utility that lets you pause or resume a printer, as well as to clear a printer queue. It also allows you to print a test page on a printer.
When troubleshooting printer problems, chances are you’ll often print test pages, which can take several steps. The neatest feature of the Prnqctl.vbs script is that it allows you to quickly print a test page right from the command line. Thus, if you were to create a simple script that automates the Prnqctl.vbs script, you could print a test page just by double-clicking an icon. To do so, you’d use the syntax:
cscript prnqctl.vbs -e [-s RemoteComputer] -p PrinterName [-u UserName -w Password]
The parameters used on this command line are detailed in Table G.
Table G
|
Parameters to use the Prnqctl.vbs script to print a test page
Learning more
I’ve introduced you to Windows XP’s six command line print utilities and offered a glimpse of how you can use them to solve common problems. However, the examples I’ve shown here represent only a small fraction of the features that these scripts offer. To learn more about all the features these scripts bring to the Windows XP operating system, access the Help and Support Center and click the Use Tools link under the Pick A Task heading. When you see the Tools page, scroll through the Tools list and select the New Command-Line Tools link, as shown in Figure A.
Figure A |
![]() |
You can find more detailed instructions for each of the six command line print utilities in the Help and Support Center. |