Mapping Printers Using Con2PRT

Posted: May 1, 2010 in Logon Script with Shell

Mapping printers through a logon script provides an easy method to remotely update printer connections. Con2PRT (Connect To Port) is a Windows 2000 Resource Kit utility used to control printer connections from the command line. The basic syntax of the con2PRT utility is as follows:

Con2prt /commands \\server\printer

Here, server is the name of the printer server containing the shared printer to map. The available commands are:

  • /F—Removes all printer connections
  • /C—Connects to the printer specified
  • /CD—Connects to the printer specified and marks it as the default printer

To remove all current printer connections and map a default printer using con2PRT, proceed as follows:

  1. Create a new directory to store all files included in this example.
  2. Select Start|Run and enter “scriptfile.bat.”

Here, scriptfile is the full path and file name of a script file that contains the following:

@Echo Off

Set Pserver=server

Set DPrinter=Printer

fullpath\con2prt /F

fullpath\con2prt /CD \\%server%\%printer%

Here, pserver is the variable holding the printer server name; dprinter is the variable holding the name of the printer share; and fullpath is the full path where con2prt is located.

Adding Printers Using the PrintUI DLL

Windows 2000/XP/2003 includes the PrintUI.dll to add and remove printers from the command line. To use the PrintUI.dll, you must call the PrintUIEntry function through the rundll32 command. To add a default printer using the PrintUI DLL, start a command prompt and enter the following:

rundll32 printui.dll,PrintUIEntry /in /y /n \\pserver\dprinter

Here, pserver is the name of the print server and dprinter is name of the printer share.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s