Software

How to take advantage of the hidden VBScript print utilities in Windows 10

Tap into the power and convenience of these obscure VBScript tools. They're easy to use, customizable, and offer a quick way to knock out printing tasks.

hero
Image: iStockphoto.com/Baloncici
Back in the Windows XP days, Microsoft provided a set of handy VBScript print utilities with the operating system. Recently, while traipsing around the Windows folder on a Windows 10 system, I bumped into those same print utilities and discovered that they still function. However, because they are buried within the operating system, they are not easy to find if you don't know they exist. So I thought I'd introduce you to these VBScript print utilities, explain why they're still useful, and describe a few example situations where these scripts can come in handy.

Why use scripts?

The first thing that probably came to mind when you read the introduction is "Why would you need to resort to script-based print utilities in Windows 10? Can't you perform all print tasks from GUI-based printer tools?" Well, there are several reasons why Microsoft has continued to provide these VBScript print utilities in Windows.

The answer to the second question is of course "Yes, you can perform all printing tasks with GUI-based printer tools." The answer to the first question is twofold: To begin with, these scripts really showcase some of the powerful features provided by Windows Script Host and Windows Management Instrumentation (WMI). Second, the scripts offer convenience and power, in that they are easy to use, customizable via command-line parameters, and offer quick and direct access to specific printing tasks.

For example, suppose that you have a printer that's used so heavily 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. Once you've replaced the ink cartridges, you could run another customized script that puts the printer back online, at which time, printing will continue as though there were never an interruption.

SEE: Five applications to expedite your printing tasks

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 because they must be run from the Command Prompt and as such, are subject to some terse rules.

The seven printer utilities, shown in Table A, are located in the C:\Windows\System32\Printing_Admin_Scripts\en-US folder, which is not listed in the path. So you must actually change to this folder to run the utilities. And since they're designed to be run from the command line, you need to launch them from a Command Prompt window and run them using Windows Script Host's command-line based script host (Cscript.exe).

Table A

Table A: The VBScript printing utilities

The basic syntax for running these scripts is
cscript printutility.vbs {parameters}

Furthermore, if any of the information contained in the parameters section contains spaces, such as This PC, you must enclose that text in quotation marks.

Let's take a closer look at some examples of when you might use these printer utilities. Keep in mind that I will describe only the parameters used in my example. Each one of the VBScript utilities has many more parameters than I will show. Be sure to read the information in the Learning more section.

Prncnfg.vbs

The Prncnfg.vbs script provides a printer configuration utility that allows you to display and change printer configuration information. It will also allow you to rename a printer.

This printer configuration utility can come in handy in a number of situations. For instance, suppose you want to build an inventory database of all the printers on your network. You can take advantage of the Prncnfg.vbs script's ability to display printer configuration information by using this command syntax:

cscript prncnfg.vbs -g [-s ServerName] -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 could later import into a database or a spreadsheet. The parameters used on this command line are defined in Table B.

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 allows you to list and examine printer drivers. This utility will also allow you 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, you use this command syntax:

cscript prndrvr.vbs -l [-s ServerName] [-u UserName -w Password]

The parameters used on this command line are defined in Table C.

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 allows you to pause, resume, cancel, and list print jobs. Suppose that there are a number of network printers you can print to 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 ServerName] [-p PrinterName] [-u UserName -w Password]

The parameters used on this command line are defined in Table D.

Table D

Table D: Parameters to configure the Prnjobs.vbs script to list all the print queue.

Prnmngr.vbs

The Prnmngr.vbs script provides a printer management utility that allows you to add, delete, and list printer connections. It will also allow you to set and display the default printer.

The Prnmngr.vbs script can come 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 ServerName] -m DriverName -r PortName [-u UserName -w Password]

The parameters used on this command line are defined in Table E.

Table E
Table E: Parameters to configure the Prnmngr.vbs script to add a new printer.

Prnport.vbs

The Prnport.vbs script provides you with a printer port management utility that allows you to create, delete, and list standard TCP/IP printer ports. It also allows you to display and change port configuration.

Suppose that you need to create a standard TCP/IP printer port. If you already have all the settings in hand, you can perform the operation quickly using the Prnport.vbs script with this syntax:

cscript prnport.vbs -a -r PortName [-s ServerName] -h HostAddress [-u UserName -w Password] [-o {raw -n PortNumber | lpr}] [-q QueueName] [-m{e | d}] [-i SNMPName] [-y CommunityName] [-2{e | d}]

The parameters used on this command line are defined in Table F.

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 allows you to 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 that you'll often find yourself printing test pages, which can be a multi-step operation. The neatest feature of the Prnqctl.vbs script is that it allows you to quickly print a test page right from the command line. So 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 ServerName] -p PrinterName [-u UserName -w Password]

The parameters used on this command line are defined in Table G.

Table G

Table G: Parameters to use the Prnqctl.vbs script to print a test page.

Pubprn.vbs

The Pubprn.vbs script provides a tool you can use to easily publish a printer to your Active Directory. To do so, you'd use the syntax:

cscript pubprn.vbs ServerName LDAP://CN=<Container>,DC=<Container>"

The parameters used on this command line are defined in Table H.

Table H

Table H: Parameters to publish a printer to Active Directory.

Learning more

This article introduced you to the the seven VBScript print utilities and offered a glimpse of how they can be used to solve common problems. However, the examples, I've shown here only represent a small fraction of the features that these scripts offer. To learn more about everything these scripts bring to the table, see Managing printing from the command line on the Microsoft TechNet site.

Also read...

What's your take?

Now that you know about the VBScript printer utilities, will you put them to use? Have you used the printer utilities in the past? If so, what was your experience? As always, if you have comments or information to share, please join the discussion.

About Greg Shultz

Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.

Editor's Picks

Free Newsletters, In your Inbox