Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


May 2006

Per-Machine Printer Connections + Custom Plug-In

The result is an easy way to manage your network printers
RSS
Subscribe to Windows IT Pro | See More Jscript Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

Managing printers is an unexciting but unavoidable responsibility for Windows systems administrators. Microsoft has put a lot of work into the Windows GUI to make printers easier to find and install, but users are still responsible for adding the printers they need to use. When printers are located together geographically or when users always log on to the same computers, adding printers can potentially be a one-time event. However, when users log on to computers in different geographical areas, adding printers can become a fairly regular occurrence. Depending on the number of users and their level of sophistication (or lack thereof), finding and installing printers can generate a lot of Help desk calls.

One reason why users might need help is that Windows' Add Printer wizard only adds printers to the current user's profile. Unfortunately, there's no option in the GUI to log on as an administrator and add one or more printers that will appear for all users. The problem gets even more complicated when a print server needs to be upgraded or replaced and users have to add the new and delete the old printers.

Microsoft must have recognized this limitation, so starting in Windows 2000, it introduced the ability to add per-machine printer connections to a computer. A per-machine printer connection is a network printer connection that appears for all users. This capability lets you add a printer to a computer only once, and any user that logs on to the computer sees the printer. Users only need to be shown how to set their default printer. In addition, in cases in which a print server is replaced, you can simply delete the old per-machine printer connections and add the new per-machine printer connections. In this scenario, users no longer need to worry about adding and deleting their own printers if the required printers are already available to them.

Strangely, this useful capability isn't well documented. Even worse, the only way to take advantage of per-machine printer connections is to type long, cumbersome commands. For example, to add the printer \\PS3\HP 4600dn as a per-machine printer connection to the computer COMPUTER2, you have to type the command

/c\\COMPUTER2 /ga 
/n"\\PS3\HP 4600dn" 

To list the per-machine printer connections on COMPUTER2, you have to run the command

rundll32 printui.dll,PrintUIEntry
  /c\\COMPUTER2 
  /ge /f"C:\Printers.txt" 

This command saves COMPUTER2's list of per-machine printer connections in a text file named C:\Printers.txt. However, this file contains more than just the printer names, so you have to edit or parse it to extract just the printer names.

As you can see, the command-based interface for managing per-machine printer connections is awkward. I needed a better solution, so I created the PMPMgr plug-in that lets me manage per-machine printer connections more easily. This plug-in consists of a Windows Script Components (WSC) file named PMPMgr.wsc and a script named PMPMgr.js. The PMPMgr plug-in provides an easy-to-use command-line interface for managing per-machine printer connections. You can download the PMPMgr plug-in by clicking the Download the Code button at the top of the Web page. To use this plug-in, you don't need to adapt the PMPMgr.wsc and PMPMgr.js files in any way. You just need to perform four steps:

  1. Register PMPMgr.wsc.
  2. Learn the PMPMgr.js command-line syntax.
  3. List the shared or per-machine printer connections.
  4. Add or delete per-machine printer connections.

STEP 1: Register PMPMgr.wsc
Before you can use the PMPMgr plug-in to manage your per-machine printer connections, you must register the PMPMgr.wsc component. The registration process adds the registry entries that make the component's object available to the system. To register the component, right-click the PMPMgr.wsc file in Windows Explorer and choose Register. Alternatively, you can register it from the command line with the command

regsvr32 /i:"[path\]PMPMgr.wsc" 
  %SystemRoot%\system32\scrobj.dll 

where path is the path to the component on your system. (Although this command appears on several lines here, you would enter it on one line in the command-shell window. The same holds true for the other multiline commands in this article.) Conversely, if you want to unregister the component, right-click the PMPMgr.wsc file and choose Unregister. To unregister it from the command line, type the command

regsvr32 /u /n /i:"[path\]PMPMgr.wsc" 
  %SystemRoot%\system32\scrobj.dll 

To run either command without displaying the dialog box message, add the /s option immediately after regsvr32 in the commands just given. You must be a member of the local Administrators group to register or unregister the component.

   Previous  [1]  2  Next 


Reader Comments
Cool. I've been looking for a way to do this for ages...

ctcmptrdr May 08, 2006 (Article Rating: )


How do I download.. I don't see a download link

jaycarnes May 10, 2006 (Article Rating: )


How do I download.. I don't see a download link

phatlt23 May 10, 2006 (Article Rating: )


Hi there, I have tried your utility and it seems to work fine till I register it and use it to view shared printers on my server. However when I try to list machine connected printers for any network computer or add a machine connected printer to any network computer (the whole point of the utility), it throws and error saying it couldn't enumerate printers because the Print Spooler service is not runnig. Now I have checked on both computers i.e. the server and where I want printers added, the Print Spooler service is running and also set to Automatic. Not sure what is going wrong here. I have tried restarting the service as well but no help. Has anyone come across this problem and resolved it? If yes then reply please.

mnit May 15, 2006 (Article Rating: )


I was able to use the native windows printui.dll commands. When I tried to use the utility I got an error at line 330, 'named' is null, or not an object. When I try to set cscript as default I got a message saying that the scripting language could not be changed. However, I recieved line error 330 even when using cscript to run the script explicitly.

j.e.taylor May 15, 2006 (Article Rating: )


Great idea but keep in mind any printers setup this way will need to be deleted this way. In looking at this printui.dll function in months past I finally found it only 1/2 useful I found no way to set the newly installed printer on the remote machine as default...what gives?

jhusted May 16, 2006 (Article Rating: )


mnit: Make sure the Windows firewall isn't blocking connections. j.e.taylor: My guess is you're usin a Windows 2000 machine without WSH 5.6. Install IE 6 or WSH 5.6. jhusted: As the article states, "Users only need to be shown how to set their default printer." That's separate from what the script component and command-line utility does. Regards, Bill

AbqBill May 19, 2006 (Article Rating: )


where is the downloadlink??

marcstrobbe May 22, 2006 (Article Rating: )


Where is the dl link?

chirishtown May 22, 2006 (Article Rating: )


Using a logon script in a GPO is a much better way to go, unless the network is very small, and without a domain. You can set the default printer, automatically prune printers that have been disconnected, use conditional statements for different users or computers...

sandiegocal May 27, 2006 (Article Rating: )


 See More Comments  1   2 

You must log on before posting a comment.

If you don't have a username & password, please register now.




Learning Path Want to know more about per-machine printer connections?
"“Predefine Printers for Computer Lab Users,”"


Want to know more about WSC?
"“Is WSC Right for You?”"

"“Use WSC to Write Reusable Code,”"

"“WSH, Part 3: Windows Script Components,”"


Want to know more about per-machine printer connections?
"“PrintUI.DLL User's Guide and Reference,”"


Top Viewed ArticlesView all articles
Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Windows Mobile: What Went Wrong?

Paul discusses the evolution of Windows Mobile and why he thinks the platform is probably doomed. ...

Microsoft Makes Windows 7 Name Official

It's official: Microsoft's next Windows version, currently being developed under the codename Windows 7 will use that moniker as its official final name when it hits the market in early 2010. The news, delivered as is so often the case these days via a ...


Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Microsoft Exchange & Windows Connections event returns to Las Vegas Nov 10 - 13
Connections returns to Las Vegas for this exciting event where each attendee will receive SQL Server 2008 standard with 1 CAL. Co-located with Microsoft ASP.NET, SQL Server, and SharePoint Connections with over 250 in-depth sessions.

Free Online Event! Virtualization:Get the Facts!
Register now and attend this free, live in-depth online conference on November 13 and 20, 2008, produced by Windows IT Pro. All registrants are eligible to receive a complimentary one-year digital subscription to Windows IT Pro (a $49.95 value)!

Check Out Hyper-V Video on ITTV
Watch Karen Forster's interview on Hyper-V's performance on ITTV.net.

Ease Your Scripting Pains with the Flexibility of PowerShell!
Join MVP Paul Robichaux on December 11, 2008 at 11:00 AM EDT as he equips you with PowerShell basics in 3 introductory lessons, each followed by a live Q&A session—all on your own computer!

PASS Community Summit 2008 in Seattle on Nov 18-21
The don’t-miss event for Microsoft SQL Server Professionals. Register now and you’ll enjoy top-notch Microsoft and Community speakers and more.



Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Email Recovery and eDiscovery for Microsoft Exchange!
Discover, Recover, and Export mailboxes, folders and individual items direct from offline EDB’s or online production Exchange Servers. Free 30 Day Demo.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing