Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 2001

Automatically Moving Users to a New Print Server

RSS
Subscribe to Windows IT Pro | See More Printing Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

Our office needed to take down and replace our aging print server. The server had 25 Data Link Control (DLC) and TCP/IP printers attached to it. I used the simple registry technique that Sean Daily discusses in the sidebar "Poor Man's Consolidation Toolkit" in "Making the Case for Server Consolidation" (May 2000) to successfully move the printers to the new server.

Rather than have my IT staff manually reconfigure our company's 200 workstations to print to the new printers, I scripted the process. I used the Microsoft Windows 2000 Resource Kit's prnmgr.vbs and prnadmin.dll utilities and the Windows NT Zero Administration Kit (ZAK) con2prt.exe tool to develop the script in Listing 1 to check users' network printer connections and redirect and connect users to the corresponding new printer.

First, the script copies the files prnmgr.vbs, prn-admin.dll, and con2prt.exe onto each workstation. Using prnmgr.vbs to list all the network printers attached to a workstation, then parsing that information to a text file lets the for statement connect a user to a new printer.

Initially, you need to input and map the old print servers to the new ones. To expedite this task, you can use prnmgr.vbs to obtain a list of all the printers attached to a network print server, then use a spreadsheet or text editor to match the old print servers to the new ones.

End of Article



Reader Comments
Getting an 'invalid character' when attempting to run this vbs script. VB is showing the % character as invalid.

Steve November 09, 2001


Good article. Q: Does this procedure work for Win9x clients as well? Specifically, do the ResKit tools and CScript work on Win95, Win98, and ME?

Kirk January 25, 2002


Works great when printername is about 18 characters or so. Our printers are typically:
xxx.state.de.us\very_long_printer_name
I wonder if this is a limitation of chgprint.exe?
The chgprint filedate here is Feb99. I'm looking for a newer version. Still a great app!...

TommyS January 24, 2006 (Article Rating: )


If I wanted to take this script and have it further parse out different printer names and run for each printer found without having to go back and edit the script for printers how would this work?

I can use FOR /F "tokens=2,2 delims=\ " %%i in (\\jerry\scripts\parseprint.txt) do @echo %%i>>\\jerry\scripts\parseprint2.txt and get the printer names into a file

How would I further change FOR /F %%i in (\\jerry\scripts\parseprint.txt) do if "%%i"=="\\foghorn\Wayland" prnmgr -dc -b "\\foghorn\Wayland"
con2prt /cd "\\hfsprint\wayland"

To pull each printer name out and make the changes as needed?

Warlords August 29, 2006 (Article Rating: )


It's all looking good so far but I'm a little confused.
Granted, con2prt will set the default printer, but I can't see anywhere in the script that determines what your default printer already is / was, in order for con2prt to set the correct corresponding new printer.

Sorry if I'm being a bit dumb here, but I'm a scripting pygmy. :-)

funchski November 21, 2006 (Article Rating: )


can some one send me acopy of you script
i dont understend were i put my old/new server config

thx

ehersko April 21, 2009 (Article Rating: )


You can obtain the script by clicking the "Download the Code Here" button at the top of the page.

Thanks for reading Windows IT Pro!

Karen Bemowski, senior editor, Windows IT Pro

KBemowski April 21, 2009 (Article Rating: )


yes i can see the code
but i dont understend were i put my old/new server config
old server mccprn new server mccpro
and my code is

if not exist %SystemRoot%\system32\prnmgr.vbs copy \\servername\prnmgr.vbs %SystemRoot%\system32
if not exist %SystemRoot%\system32\con2prt.exe copy \\servername\con2prt.exe %SystemRoot%\system32
if not exist %SystemRoot%\system32\prnadmin.dll copy \\servername\prnadmin.dll %SystemRoot%\system32

if exist %temp%\printers.txt del %temp%\printers.txt
if exist %temp%\parseprint.txt del %temp%\parseprint.txt
if exist %temp%\printout.txt del %temp%\printout.txt
REM *Makes sure that prnmgr.vbs, prnadmin.dll, and con2prt.exe exist on the workstation*

%systemroot%\system32\regsvr32.exe /s %systemroot%\system32\prnadmin.dll >nul
REM *Registers prnadmin.dll*

CScript //H:CScript //S 1>nul 2>nul
REM *Sets Cscript as the default script language for the local PC’s OS and sends output to a file*

prnmgr -l >%temp%\printers.txt
REM *Prints a list of attached network printers to a text file*

find "PrinterName" %temp%\printers.txt >%temp%\printout.txt
REM *Finds the line PrinterName and sends to a new text file*

FOR /F "tokens=2,2 delims=: " %%i in (%temp%\printout.txt) do @echo %%i>>%TEMP%\parseprint.txt
REM *Parses and leaves only the UNC name of network printer to a text file*

FOR /F %%i in (%TEMP%\parseprint.txt) do if "%%i"=="\\printserver\X001" prnmgr -dc "\\printserver\X001" && con2prt /cd "\\newservr\hplaserj"

ehersko April 22, 2009 (Article Rating: )


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Confirmed: Battery Life Issues Not Windows 7's Fault

Microsoft on Monday issued a lengthy statement about the recent Windows 7 battery controversy, echoing my assessment from earlier in the day, but backing it up with hard, cold evidence. ...

Microsoft Warns of Windows Version Expirations

Microsoft warned that this year will see three out-of-date Windows versions slip into retirement. ...

Battery Life Issues Almost Certainly Not Windows 7's Fault

While Microsoft is still investigating a notebook battery life issue that was supposedly caused by Windows 7, some interesting trends have emerged. ...


Task Automation Whitepapers Three Ways to Prevent Insider Risk within Your SCCM-Managed Environment

From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Managing IT Across Multiple Locations

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 Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


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 DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2010 Penton Media, Inc. Terms of Use | Privacy Statement