"Sight" Survey   (SS42)

 

Printer Port Capture in Windows NT and 2000

Windows NT Print Capture is set up and controlled by Windows NT Command-line programs. These are Windows NT programs that do not have a GUI (graphical user interface) and are accessed and run through an NT Command Prompt Window. Although the Command Prompt window is often referred to as the "DOS window" (and has an MSDOS icon), print redirection is not itself a DOS program, but an NT Systems Administration tool. These tools are powerful, and can cause problems if misused: accordingly they should only be used by System Administrators.

All the issues discussed here are Windows NT issues. However we have found that the topic of print redirection is so poorly covered in the Windows documentation that we are putting together this paper in self defense! We assume that you are an NT Administrator, generally familiar with how to set up and configure NT, but unfamiliar with this specific topic - redirection. Getting into the more general how and why of administering NT is well beyond the scope of this document - there are numerous courses and books available on the subject.

These network control programs are accessed through the NET command, optionally followed by parameters that direct what part of the network setup is to be displayed or changed, and what the desired effect of any changes is. The following is a hands-on tutorial style explanation of print capture. The source material is taken directly from Windows NT 4.0, but as far as I'm aware there is no explanation in the supplied Windows documentation, on-line or printed, that explains the why, what, and how.

To use the NET command, first open a Command Prompt window. Type NET /? and press Enter. The resulting dialog is shown below. Commands you type are shown in Courier BOLD.  The computer responses are show in Courier only (not bold).

C:\>net /?
The syntax of this command is:

NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
    HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |
    SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]

You will see that one of the options (near the end of the list) is USE. Next, display the somewhat cryptic Help file for the NET USE variation of the command. To do this type:

NET HELP USE | MORE

and press Enter. The "|" symbol is the vertical bar, sometimes known as "pipe", and usually found as the "shift" option of the "\" (back slash) key. Adding | MORE to the command displays the help one screen at a time.

C:\>net help use | more
The syntax of this command is:

NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]]     [/USER:[domainname\]username]
    [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE [devicename | *] [password | *]] [/HOME]

NET USE [/PERSISTENT:{YES | NO}]

NET USE connects a computer to a shared resource or disconnects a computer from a shared resource. When used without options, it lists the computer's connections.

devicename

Assigns a name to connect to the resource or specifies the device to be disconnected. There are two kinds of devicenames: disk drives (D: through Z:) and printers (LPT1: through LPT3:). Type an asterisk instead of a specific devicename to assign the next available devicename.

 

\\computername

Is the name of the computer controlling the shared resource. If the computername contains blank characters, enclose the double backslash (\\) and the computername in quotation marks (" "). The computername may be from 1 to 15 characters long.

 

\sharename

Is the network name of the shared resource.

 

\volume

Specifies a NetWare volume on the server. You must have Client Services for Netware (Windows NT Workstations) or Gateway Service for Netware (Windows NT Server) installed and running to connect to NetWare servers.

 

password

Is the password needed to access the shared resource.

 

*

Produces a prompt for the password. The password is not displayed when you type it at the password prompt.

 

/USER

Specifies a different username with which the connection is made.

 

domainname

Specifies another domain. If domain is omitted, the current logged on domain is used.

 

username

Specifies the username with which to logon.

 

/HOME

Connects a user to their home directory.

 

/DELETE

Cancels a network connection and removes the connection from the list of persistent connections.

 

/PERSISTENT

Controls the use of persistent network connections. The default is the setting used last.

 

YES

Saves connections as they are made, and restores them at next logon.

 

NO

Does not save the connection being made or subsequent connections; existing connections will be restored at next logon. Use the /DELETE switch to remove persistent connections.


NET HELP command | MORE

Displays Help one screen at a time.

To display the redirections, if any, on your computer use the NET USE command without any parameters, as shown below. The computer responses are for my particular computer (the one I'm writing this on). Yours will certainly be different.

C:\>net use
New connections will be remembered.

Status       Local    Remote             Network
----------------------------------------------------------------------
Disconnected H:       \\486-66-A\C       Microsoft Windows Network
Disconnected I:       \\486-66-A\D       Microsoft Windows Network
OK           LPT2     \\MOON\hplaserj    Microsoft Windows Network
OK           LPT3     \\MOON\hplaserj    Microsoft Windows Network
OK                    \\MOON\IPC$        Microsoft Windows Network

The command completed successfully.

The first line of the output tells you that NET USE is currently set to remember changes you make to the configuration. This is usually necessary, as you don't want to make the changes over and over again. Changing this setting is explained below.

The output also shows that my computer's H: drive is in fact the C: drive on the computer named \\486-66-A. The "Disconnected" label shows that that computer is not on the network at the moment (it was actually switched off). Similarly my I: drive is the D: drive on that computer.

Also shown are my computer's LPT2 and LPT3 ports, both of which are connected to the printer whose "sharename" is "hplaserj" and which is controlled through the computer called "MOON." In this particular case the printer is a Hewlett-Packard PCL3 LaserJet, connected to an Ethernet network through an HP JetDirect box, and the driver was installed (and the print queue managed) by MOON. The OK label shows that last time my computer tried to access LPT2 it was successful (it does not necessarily mean that it's OK right now).

In the following, I assume that you do not have a printer physically connected to port LPT2 on your computer. If your computer does not have a printer on LPT2, or does not have an LPT2 port, it will behave like mine. If it does have a printer on LPT2 then setting up LPT2 redirection will route all print output from the local printer to the network printer. Removing redirection will stop this routing and the local printer will work again.

Let's try disconnecting port LPT2 from the network printer. To do this we use the command with the /delete option:

C:\>net use LPT2 /delete
LPT2 was deleted successfully.

Now display the redirections once again, with NET USE:

C:\>net use
New connections will be remembered.

Status        Local     Remote           Network
----------------------------------------------------------------------
Disconnected  H:        \\486-66-A\C     Microsoft Windows Network
Disconnected  I:        \\486-66-A\D     Microsoft Windows Network
OK            LPT3      \\MOON\hplaserj  Microsoft Windows Network
OK                      \\MOON\IPC$      Microsoft Windows Network

The command completed successfully.

Notice that port LPT2 is no longer re-directed. You can only tell this by noting that LPT2 (like LPT1) does not appear in the redirection list.

To set up a redirection (or, in this case, restore one you deleted) use the command sequence:
 

C:\>net use lpt2 \\moon\hplaserj
The command completed successfully.

...and once again, check the results:

C:\>net use
New connections will be remembered.


Status   Local      Remote            Network
----------------------------------------------------------------------
Disconnected H:     \\486-66-A\C      Microsoft Windows Network
Disconnected I:     \\486-66-A\D      Microsoft Windows Network
OK           LPT2   \\MOON\hplaserj   Microsoft Windows Network
OK           LPT3   \\MOON\hplaserj   Microsoft Windows Network
OK                  \\MOON\IPC$       Microsoft Windows Network

The command completed successfully.

To test whether redirection is successful, use the COPY command to copy from the screen (CON, short for Console) to the printer port (in this case LPT2) as follows:

C:\>copy con lpt2
Mary had a little hippopotamus ^L^Z
1 file(s) copied.

The message "1 file(s) copied" means you were successful. Note that ^L means Ctrl-L (press and hold the Ctrl key; press and release the L key; release the Ctrl key), and ^Z means Ctrl-Z. Do not type the ^ character! You should get one sheet of paper with "Mary had a little hippopotamus" printed on it. If redirection is successful, but you get scrambled printing (or none at all), you probably have an inexpensive "Windows Only" printer. These printers are of limited use, and are generally unsuitable for CAD applications. While you are experimenting, you may want to monitor the print queue foe the redirected printer so you can watch what is happening.

If redirection is not successful (and you have no local LPT2 print capability) you'll get this message:


C:\>copy con lpt2
Mary had a little hippopotamus ^L^Z
The system cannot find the file specified.
0 file(s) copied.


If you're not sure what computers are accessible to you on the network you can use the NET VIEW command:


C:\>net view

Server Name                 Remark
----------------------------------------------------------------------
\\CRW-P2
\\MOON
\\RWB586

The command completed successfully.

…and to find out the resources available to you on a specific computer, use NET VIEW <computername> like this:


C:\>net view \\moon
Shared resources at \\moon


Share name    Type    Used as    Comment
-----------------------------------------------------------------------
CDROM_S       Disk
HPLaserJ      Print   LPT3       HP LaserJet Series II
MOON-C        Disk
NETLOGON      Disk               Logon server share

The command completed successfully.


You turn "remembering" on and off like this. Turn it off:

C:\>net use /persistent:no
The command completed successfully.

C:\>net use
New connections will not be remembered.


Status       Local    Remote             Network
-----------------------------------------------------------------------
Disconnected H:       \\486-66-A\C       Microsoft Windows Network
Disconnected I:       \\486-66-A\D       Microsoft Windows Network
OK           LPT2     \\MOON\hplaserj    Microsoft Windows Network
OK           LPT3     \\MOON\hplaserj    Microsoft Windows Network
OK                    \\MOON\IPC$        Microsoft Windows Network

The command completed successfully.

...and to turn it back on again:

C:\>net use /persistent:yes
The command completed successfully.

C:\>net use
New connections will be remembered.

Status       Local    Remote             Network
----------------------------------------------------------------------
Disconnected H:       \\486-66-A\C       Microsoft Windows Network
Disconnected I:       \\486-66-A\D       Microsoft Windows Network
OK           LPT2     \\MOON\hplaserj    Microsoft Windows Network
OK           LPT3     \\MOON\hplaserj    Microsoft Windows Network
OK                    \\MOON\IPC$        Microsoft Windows Network

The command completed successfully.


In each of the two cases note the change in the first line of the computer's response.

 

 

  SimSystems Home             Sight Survey FAQ Index

 

© 2008 by Carlson Software, Inc.   Last modified November 18, 2008