Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

October 31, 2001 12:00 AM

Automatically Moving Users to a New Print Server

Windows IT Pro
InstantDoc ID #22699
Rating: (6)
Downloads
22699.zip

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.

Related Content:

ARTICLE TOOLS

Comments
  • Eran
    3 years ago
    Apr 22, 2009

    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"

  • Karen
    3 years ago
    Apr 21, 2009

    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

  • Eran
    3 years ago
    Apr 21, 2009

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

    thx

  • m
    6 years ago
    Nov 21, 2006

    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. :-)

  • Stephen
    6 years ago
    Aug 29, 2006

    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?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.