Windows provides a very nice graphical interface for linking to and managing network printers. However, there are times when you need to attach to a printer but a GUI won’t get the job done. For example, you may need to create a printer mapping through a logon script or through a batch file. For these jobs, you’ll need a printer management utility that can function at the command-line level. The Con2prt utility is just the thing.
Acquiring the Con2prt file
The Con2prt utility is a part of the Microsoft Zero Administration Kit. The Zero Administration Kit is a set of utilities and documentation designed to help you to minimize the workload involved in managing Windows workstations.
Download the right file
When downloading the Microsoft Zero Administration Kit, be careful about which file you download. One of the files is the actual Zero Administration Kit, while the other file is the documentation only. You’ll need the full kit.
The Zero Administration Kit consists of a 5.78-MB executable file named Zak.exe. Simply download this file to an empty folder and then run it. The extraction program will ask you for a location in which to extract the files. Simply specify the name of the folder in which you originally downloaded the Zak.exe file, and the extraction program will create the necessary directory structure within that folder. The Con2prt.exe file exists within the \I386\Tools folder.
Using the Con2prt utility
Now that you’ve downloaded and extracted the Con2prt utility, let’s talk about how to use it. Since the utility is designed to operate from a command prompt, begin by opening a command prompt window. The actual method for doing so will vary slightly depending on the version of Windows that you’re using, but in a Windows XP environment, you can access the command prompt window by clicking Start | All Programs | Accessories | Command Prompt.
Once you’ve opened the command prompt, you’ll probably want to jump right in and start using Con2prt. However, you need to gather a bit of information first. You need to know the name of the server that’s hosting your network printers and the share name for the printer that you want to interact with. There are a couple of ways to do this, but the easiest technique is to use the Net View command. Simply follow the Net View command with a double backslash and a server name, and you’ll see a list of all of the shared resources on the server. For example, I have a file and print server named Tazmania. Here’s what happens when I run the Net View command against this server:
C:\Documents and Settings\Administrator>net view \\tazmania
Shared resources at \\tazmania
Share name Type Used as Comment
CertEnroll Disk Certificate Services share
HP Print Black and white, laser printer.
HPOffice Print HP OfficeJet G Series
NETLOGON Disk Logon server share
Software Disk R:
SYSVOL Disk Logon server share
The command completed successfully.
After entering net view \\tazmania, I was presented with a list of Tazmania’s shared resources. These resources include both file and print resources, but the print resources are what we’re interested in. Notice that in the list of resources, there’s a black-and-white laser printer with the share name of HP. This is the printer I’ll be using in this article.
The next step is to navigate to the folder containing the Con2prt utility. The location will vary, depending on the location of the extracted files. On my machine, I extracted the files to a folder named C:\zak. Therefore, my copy of the Con2prt.exe file would be in C:\zak\I386\tools. To navigate to this folder, I’d enter the following commands. The commands will be slightly different on your machine, depending on the file path.
Now that the command prompt has been redirected to the correct location, enter the Con2prt /? command. Entering this command will show you the command’s syntax. The command’s syntax looks something like this:
CON2PRT [ /? | /H | /F [/C \\SERVERNAME\SHARENAME | /CD \\SERVERNAME\SHARENAME]+]
Now, let’s look at the syntax in more detail.
- /? or /H—As you’ve already seen, the /? switch displays the help file. The /H switch does the exact same thing as the /? switch. Keep in mind both the /? and the /H switches must be used exclusively.
- /F—Deletes all current printer connections. The /F switch can be used either exclusively or in conjunction with the /C or the /Cd switch.
- /C—Connects your system to the printer that you specify.
- /CD—Makes the Con2prt utility attach to a printer but sets the connection up to be the default printer.
Now that you know what the switches do, let’s examine them in action.
First, let’s pretend that we want to disconnect all of the currently connected printers. To do so, you’d enter this command:
If you wanted to disconnect from all currently connected printers and then connect to the printer at \\tazmania\hp, you’d use the following command:
CON2PRT /F /C \\tazmania\hp
You can use the /F switch in conjunction with either the /C or the /Cd switch. The one thing that you must remember, though, is that the /F switch must come first when you’re using one of these other switches—otherwise, you’ll disconnect the printer that you just connected. Likewise, you could accomplish the same task by entering two commands rather than combining the functionality into a single command. In the code sample below, the first line would sever the existing printer connections, and the second line would establish a connection to \\tazmania\hp.
CON2PRT /C \\tazmania\hp
Of course, there’s no reason why you’d have to sever all of the existing printer connections if you didn’t want to. You could simply use the Con2prt /C \\tazmania\hp command on its own. Finally, to attach to a printer and make it the default, just enter this command:
CON2PRT /CD \\tazmania\hp
Like the /C switch, you can use the /Cd switch exclusively or in conjunction with the /F switch.
The Net Use command as an alternative
If the syntax that I’ve shown you looks familiar, it’s because the Con2prt utility isn’t the only utility to offer such functionality. The Net Use command also allows you to connect to and disconnect from network printers. With the Net Use command, you can even specify port numbers. For example, the command net use lpt1: \\tazmania\hp would connect the printer \\tazmania\hp to the LPT1 printer port. You can read more about the syntax of the Net Use command by entering net use /? at the command prompt.