Connecting
an MS-Dos Application to a Printer on a USB Port
on Windows 2000
by Curtis Krauskopf
DataFlex, an MS-Dos application, was written in an era when the only printer
ports were serial ports and parallel ports.
A USB port is a completely foreign concept to character
mode DataFlex. From
DataFlex's point of view, printing to a USB port is
as odd as trying to print to the status lights on the
keyboard. The DataFlex character mode runtime was never
designed to write to a USB port called USB001:.
Despite that, and because of Windows 2000's flexibility,
DataFlex can be coaxed into printing character mode
documents to a USB printer with any type of printer
ink.
The solution is to assign the USB-connected printer
a network name, and then to associate that network name
with an unused LPT port. The DataFlex program will print
to the LPT port and Windows will automatically redirect
the job to the USB printer port.
The first step is to install the USB printer
normally into Windows. The easiest installation
is when Windows 2000 automatically recognizes the
printer. This typically happens when you're using
a name-brand printer or when the printer had previously
been installed on the computer.
In most situations, you need to be logged in as
an administrator, or as a user with administrator
security privileges.
2.
Once the printer is installed and the obligatory
test pages print correctly, proceed to the following
steps.
Find the resource name for the computer. Resource
names are also called network names or
share names. On Windows 2000, computers
are assigned network names even if they aren't attached
to a network. Your computer's network name might
have been assigned by the computer manufacturer,
or maybe by your IT department, or it might have
been assigned when you originally installed Windows
2000. Substitute your computer's resource name with
computer_name in these
instructions.
Find out the printer's resource name. Generally,
the name is assigned during printer
installation and it might have been assigned
automatically. Just like resource (network) names
for computers, printers are assigned network names
even if you're not attached to a network. In these
instructions, substitute printer_name
for the share name assigned to your printer.
Resource names (also called share names or network
names) can contain letters, digits and a few special
characters, like spaces (blanks). Even though share
names can contain spaces, I recommend not
putting spaces in resource names. The reason is
because it's more difficult to use operating system
commands when spaces exist in the resource name.
Figure 1 shows an example of an operating system
command that will not work because the resource
name (in this example, a computer cleverly named
"my computer name") contains blanks.
net view \\my
computer name
Figure 1: This command will not
work because spaces are in the computer
name.
If the network administrator for your system insists
on names with embedded spaces, figure 2 shows a way
to do it.
net view \\"my computer name"
Figure 2: This command will work when
spaces are embedded in a computer name.
As shown in figure 2, double quotes are used to tell
Windows 2000 that the words my computer name
belong together.
Open an operating system command prompt. The operating
system command in figure 3 assumes that LPT1 is
an unused port. At the operating system prompt,
enter the command shown in figure 3....
net use LPT1 \\computer_name\printer_name /Persistent:Yes
Figure 3: This command defines a persistent
printer connection to LPT1 for a computer
cleverly called computer_name and a printer
called printer_name.
where:
LPT1 is the name
of the unused parallel printer port. Note that
a colon (:) does not appear after the
port name on the command line.
\\computer_name
is the resource name of the computer that is
attached to the USB printer.
printer_name is
the resource name (share name) of the USB printer
discovered in step 4.
/Persistent:Yes
denotes that this connection should be reestablished
when the system is rebooted.
If the command line above is wrapping to two lines
then widen your browser's window because the above
command is on one line.
Figure 4 shows an example of using the command in Figure 3. In
Figure 4, the computer is named Dell and the printer is named HP.
net use LPT1 \\Dell\HP /Persistent:Yes
Figure 4: This example shows how to use the command in Figure 3.
Figure 5 is another example of the command in Figure 3, but blanks (spaces)
are inside the resource names. In figure 5, the computer's resource name
is "Dell Computer" and the printer's name is "HP Printer".
net use LPT1 \\"Dell Computer\HP Printer" /Persistent:Yes
Figure 5: When one or both of the resource names contain blanks
(spaces), surround the entire resource name with double quote characters (") to
tell the operating system that the words belong together.
A note about /Persistent:Yes:
The /Persistent:Yes
parameter will tell Windows 2000 to reestablish
the connection when the system is rebooted.
If the printer is not connected to the computer
when it boots, Windows 2000 will usually remember
the connection anyway. Depending on your system's
defaults and security settings, Windows 2000
might even ask if you want to have the printer
connection deleted when Windows 2000 can't find
the printer anymore.
However, the operating system is not perfect
at remembering that you specified /Persistent:Yes.
I have seen situations where Windows 2000 seemed
to spontaneously decide that the printer connection
wouldn't be defined after a reboot even though
the printer was connected to the computer and
powered on. When that happens, the only way
to reestablish the connection is to follow the
above instructions. You can
to help you remember how to reestablish the
printer connection.
The command in figure 3 can be inserted into the autoexec.bat
or network login script, whichever is most appropriate
for your installation. If you do that, eliminate the
/Persistent:Yes parameter
because you're making the connection persistent by
using the autoexec.bat or network login script.
7.
The command in figure 6 shows how to verify that
the connection was successful. Enter the command at
the operating system prompt.
net view \\computer_name
Figure 6: Verify that the connection
was successful.
8.
After the LPT port has been associated with the
USB port, open the printer configuration panel:
Start
Settings
Control Panel
Printers
Right Click on the Printer to display its context
menu
Choose Properties from the context menu
Change the data stream from RAW to Text mode. Use
these steps:
Choose the Advanced tab or button
Choose the Print Processor button
In the Data Type section, change the data type
from RAW to TEXT.
Apply and Close the printer panel.
The command in figure 7 shows another way to test
that the printer has been successfully configured.
Enter the command at an operating
system prompt.
dir > lpt1:
Figure 7: Test the printer connection by sending data to it.
Small directory listings won't have enough
information to force a page to eject, so you
might have to repeat this a couple times to
get a page to actually print.
Deleting the USB Connection
The command in figure 8 shows how to delete the LPT
port connection.