TCS - Ports of Call: DOS System Device Drivers, Part 2

Ports of Call: DOS System Device Drivers, Part 2

by Ken Johnson
Tulsa Computer Society
From the June 1998 issue of the I/O Port Newsletter

Last month, we began looking at your computer's system device drivers, the gateway between the inside of your computer and things you need outside. Device drivers are special programs loaded into memory when your computer starts. Typically they provide an interface between the operating system and a piece of hardware. DOS has several built-in device drivers, called system device drivers, which are loaded automatically at bootup. These include:

COM1-- First serial COMmunication port, typically connected to a mouse or modem COM2 -- Second serial communications port, typically connected to a mouse or modem, the one NOT on COM1

COM3 -- Third serial communications port

COM4 -- Fourth serial communications port

AUX -- AUXiliary device, by default the same as COM1

LPT1 -- First parallel port, typically connected to the printer (LPT stands for Line PrinTer)

LPT2 -- Second parallel port

LPT3 -- Third parallel port

PRN -- PRiNter, same as LPT1

CON -- Keyboard and Display (CONsole)

CLOCK$ -- Real-time clock

NUL -- A "Bit-bucket" device that goes to nothing; anything sent to NUL will simply disappear

A:-Z: -- The drive letters

This month we'll continue with AUX, PRN, and some tricks using LPT1 in DOS and Windows.

By any other name

AUX and PRN are special device drivers that really mean something else. By default, AUX is the same as COM1. However, it is available for other hardware to use (a peripheral's setup program may define AUX for its use, which is fine with DOS). PRN is the same as LPT1; at bootup, DOS configures PRN to direct any communications to LPT1. PRN always equals LPT1 in DOS's view. There is no way to reconfigure PRN to another parallel port (like LPT2) using just DOS commands. Third-party utilities are available if you need to do this.

Fun with LPT1/PRN

You probably know one of the most common uses of PRN and LPT1 is to send DOS output to the printer instead of the screen, by using redirection. For example, to get a listing of the current directory or folder, use
Since PRN is the same as LPT1 to DOS, you could also use

If you need to direct the output to another port, simply substitute its name. For example, if you have an older serial printer on COM1, the command would be

Of course, DOS won't nicely eject the page from the printer, but you can also do that by using redirection to PRN. Enter the following on the command line
Type ^L by holding down the Ctrl key and pressing the letter L (CTRL-L).

This redirection to PRN is also a good way to check if the communication path to your printer is working correctly. If DIR > PRN works, then the port communication from DOS is good. However, if you have a postscript printer, this test won't work. Instead, you need to copy the TESTPS.TXT file, in the \WINDOWS\SYSTEM directory, to the printer

Copying to the printer port has another advanced use -- printing formatted output when you don't have the application that created that output. For example, let's say you create a WordPerfect document at home, and want to print it out on a color printer at work. But the PC at work connected to that printer doesn't have WordPerfect loaded on it. Create the document at home with all the appropriate formatting for that color printer, then "print" the document to a file. This file, often with a .PRN extension, will contain all the necessary formatting and printer commands. Now at work, copy the file to the printer and the output will look like you printed it directly from WordPerfect. If the print file is called PROPOSAL.PRN, the command would be

The /B specifies a "binary" copy. This tells DOS the file is not an ASCII file and to ignore any end-of-file markers (Ctrl-Z) that are in the file. Without /B, DOS will stop the copy if it comes upon a Ctrl-Z.

Printing Folder Contents in Window 95

Using DIR > PRN is an easy way to print a directory from DOS. But in Windows 95 it's a hassle to drop out to DOS to print the listing of a folder's contents. However, with an easy setup, printing a directory of a folder can be only a right-click away. Follow these steps:

1. Create a batch file in the Windows directory called DIRPRINT.BAT. Include the following line:

2. Using Explorer, right-click on C:\WINDOWS\DIRPRINT.BAT. Select Properties. Under the Program tab, select Run Minimized and check the Close on Exit box.

3. Back in Explorer, select View, Options, then the File Types tab. Scroll down and highlight the Folder type. Choose Edit.

4. Select New. Fill in Directory Print for Action, and in the application line type C:\WINDOWS\DIRPRINT.BAT. Close back to Explorer.

What we have done here is add a new action called Directory Print to the context menu for a folder (the context menu displays when you right-click on an item). Now to print a directory listing for a folder in Explorer, right-click on the open folder icon and select Directory Print.

Setting up a file action type for Folders
that will include a Directory Print option
for the right-click context menu.

If your printer doesn't automatically eject the page from the printer, add
to DIRPRINT.BAT after the DIR > PRN command. Remember the ^L is entered by pressing CTRL-L; if using DOS's EDIT program, press CTRL-P, then CTRL-L.

Printing .PRN or .PS files in Window 95

If you regularly print formatted printer (*.PRN) files or Postscript (*.PS) files, you can configure Window 95 to print these files quickly and easily. Follow these steps:

1. Create a batch file in C:\WINDOWS called PRNPRINT.BAT. Include the line

2. Using Explorer, find C:\WINDOWS\PRNPRINT.BAT. Right-click on the filename, select Properties, then choose the Program tab. Under the Run selection select Minimized, and check the Close on Exit box. You can also change the icon if desired.

3. Back in Explorer, select View, Options, then the File Types tab. Choose New Type.

4. In Description of Type, enter Printer. For Associated Extension, enter PRN or PS as appropriate for your printer.

5. Click on the New button.

6. For Action, enter Printer. For Application used to perform action, enter C:\WINDOWS\PRNPRINT.BAT. Click OK, then click Set Default. This makes Print (using PRNPRINT.BAT) the default action when you double click on a PRN (or PS) file in Explorer. Close back to Explorer.

Now when you want to print a PRN (or PS) file, simply double-click on it.

Next month we'll conclude our ports of call, with CON and NUL.

Kenneth E. Johnson is author of "The Lawyer's Guide to Creating Web Pages," and the forthcoming "Lawyer's Quick Guide to E-Mail." He is Assistant Editor of the American Bar Association's Network 2d newsletter, Contributing Editor of Practical Windows magazine, columnist for the Computer for Lawyers Newsletter, and a member of Microsoft's Legal Industry "Ask the Experts" panel. He is also WebMaster of the ABA's

For more information on the Tulsa Computer Society click here

This page has been accessed times.
Tulsa Computer Society 1/23/99
Don Singleton, President