STEP 2: Learn the PMPMgr.js Command-Line Syntax
After you've registered the PMPMgr.wsc component, you'll be able to use PMPMgr.js. This script's command-line syntax is as follows:
[cscript] PMPMgr.js [[@]computer]
/shared | /list | /exists:[@]printer |
/add:[@]printer | /delete:[@]printer
Here's a description of each syntax element:
- The cscript keyword at the beginning of the command is only required when CScript isn't your default script host. To set CScript as your default host, run the command
cscript //H:CScript //Nologo //S
- The computer argument specifies a computer name. If you use the @ character, the computer argument refers to a text file containing a list of computer names (one name per line). If you don't specify this argument, PMPMgr.js assumes the current computer.
- The /shared option lists the printers shared from the print server(s) specified by the computer argument.
- The /list option lists the per-machine printer connections on the computer(s) specified by the computer argument.
- The printer argument specifies a printer name in Universal Naming Convention (UNC) format (\\printserver\printername). If the printer name contains spaces, enclose it in double quotes (" "). If you use the @ character, the printer argument refers to a text file containing printer names in UNC format (one name per line).
- The /add option adds the per-machine printer connection(s) specified by the printer argument.
- The /delete option deletes the per-machine printer connection(s) specified by the printer argument.
STEP 3: List the Shared or Per-Machine Printer Connections
The PMPMgr.js script's /shared option lists the shared printers shared from a print server. For example, you can run the following command to list the printers on the print server named PS1:
PMPMgr.js PS1 /shared
PMPMgr.js produces tab-delimited output that you can redirect to a text file. Figure 1 shows an example of the script's output.
You can also list the printers shared from multiple print servers with a single command. Place a list of print servers in a text file, and specify the text file's name immediately following the @ character. Figure 2 shows a sample text file, PrintServers.txt. The following command lists the shared printers for each computer specified in the Print-Servers.txt input file and redirects the results to the PrintServers.tsv output file:
PMPMgr.js @PrintServers.txt
/shared > PrintServers.tsv
To list the per-machine printer connections installed on one or more computers, use the /list option instead of the /shared option in the command just given.
STEP 4: Add or Delete Per-Machine Printer Connections
To add or delete per-machine printer connections, you use the PMPMgr.js script's /add or /delete option, respectively. For example, the following command adds the printer \\PS2\HP LaserJet 1300 to the computer RECEPTION1:
PMPMgr.js RECEPTION1
/add:"\\PS2\HP LaserJet 1300"
To add or delete multiple printers at once, you can create a text file that contains a list of printers, one printer per line. Figure 3 shows a sample text file, Printers.txt, that contains a list of printers. The following command adds the printers in listed Printers.txt to the computer RECEPTION2:
PMPMgr.js RECEPTION2
/add:@Printers.txt
Note that if a user is logged on when you add or delete per-machine printers, the changes won't appear in the user's Printers window until the next time he or she logs on. To see the changes immediately, you need to restart the computer's Print Spooler service.
I designed the PMPMgr.wsc component and PMPMgr.js script to be tolerant of errors, but you must run PMPMgr.js under an account that's a member of the current computer's local Administrators group. If you're working with remote computers, you must be a member of each remote computer's local Administrators group as well. If you run PMPMgr.js under an account with insufficient permissions, you might see a Printer User Interface dialog box, which will pause the script. You must dismiss the dialog box before the script will continue.
A Better Way to Manage Printers
Per-machine printer connections have saved me a lot of time and trouble. The PMPMgr plug-in makes using these connections much easier. Download the PMPMgr.wsc and PMPMgr.js files and start taking advantage of per-machine printer connections today.
Solution Snapshot
PROBLEM: The command-based interface to manage per-machine printer connections in Windows 2000 and later is awkward.
SOLUTION: Use the PMPMgr plug-in to more easily manage per-machine printer connections.
WHAT YOU NEED: PMPMgr.wsc, PMPMgr.js, Windows 2000 or later, Windows Script Host (WSH) 5.6
DIFFICULTY:
3 out of 5
SOLUTION STEPS:
- Register PMPMgr.wsc.
- Learn the PMPMgr.js command-line syntax.
- List the shared or per-machine printer connections.
- Add or delete per-machine printer connections.
|
End of Article
ctcmptrdr May 08, 2006 (Article Rating: