There are two alternatives if you don't have a printer connected directly to your PC's printer port (for instance, if your printer is connected via a USB cable or is on your network). The first is to send the DIR
command's output to a file, a file you can later open and print from within Windows. Let's call the file DIRLIST.TXT
. When you type:
DIR > DIRLIST.TXT
the above command redirects the DIR
command's output to DIRLIST.TXT
, which is created in the same directory. You can then use Notepad to print the file by issuing this command:
NOTEPAD /P DIRLIST.TXT
The command opens Notepad, loads the file DIRLIST.TXT
, prints the file (thanks to the /P
switch), then closes Notepad back up. A final command is required to remove the DIRLIST.TXT
file:
DEL DIRLIST.TXT
There is no confirmation; the file is removed by the DEL
command. (Also, it cannot be recovered from the Recycle Bin.)
The second alternative is available to Windows Vista users only. With Windows Vista, Microsoft added a slew of new DOS commands, including a new filter: CLIP
. The CLIP
filter is used at the command prompt to send information to the Windows clipboard. Once there, the text generated by the command prompt can be pasted into any Windows application that accepts text.
So in Vista, the alternative for printing a list of files works like this:
DIR | CLIP
The above command uses the pipe character (found above the backslash key on your keyboard) to send the output of the DIR
command to the Windows clipboard. You can then use the Ctrl+V
, or Paste, command to paste the file listing into any application that accepts text, such as Notepad or Microsoft Word.
What else is there?
The command prompt is truly a rich environment in which to use your computer. I hope these few examples have given you an insight into its power and hint at why so many power users are enamored of it.
When you get good, you'll want to explore batch files -- strings of commands that truly show off the command prompt's power to automate various computing chores. (Look for an upcoming Computerworld story on just that topic.)
Sure, DOS may be a relic. But it's a holy relic, and it deserves a place of honor in your computer cathedral.
Working the window You can change the row count simply by resizing the window vertically with your mouse. However, the same can't be said for the horizontal axis. To change the command prompt window's column count, you need a DOS command,
The above command sets the number of text columns (COLS) on the Note, however, that setting the
It's also possible to change the command prompt window's text and background colors, something old-time DOS users requested for years. Try this:
The above command sets the background color to 1 (blue) and text color to F (bright white). There are 16 color combinations to choose from, as shown below.
The order is always background first, then text color -- so |
||||||||||||
Dan Gookin has written more than 111 books about computers, including the original Dummies book, DOS For Dummies. His latest title is Find Gold in Windows Vista.
An earlier version of this article included incomplete information about the IPCONFIG
command that has since been corrected.