DOS lives! Secrets of the Windows command prompt

Don't be afraid of a little typing. Lots of good old DOS commands still work in Windows, and often they're the best choice for quick and efficient work.

1 2 3 4 5 6 7 8 Page 8
Page 8 of 8

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?

clear.gif

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.

clear.gif
clear.gif
 
clear.gif

Working the window
In Windows, what's left of DOS dwells within the confines of a window, but you have more control over how the command prompt and its text appear in that window than users in the pre-Windows 95 era ever did.

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, MODE:

MODE CON COLS=90 LINES=30

The above command sets the number of text columns (COLS) on the CON or "console" (another term for the command prompt window) to 90 and the number of rows or LINES to 30. Feel free to substitute other values for COLS or LINES to set the command prompt window to exactly the dimensions you require.

Note, however, that setting the LINES value also affects the command prompt window's ability to scroll back through commands. Normally, the number of lines is set to 300, though the window is sized to show only 25 lines. When you reset the LINES value, the scroll-back buffer will be reset as well, so tread carefully if you think you're going to need to scroll back through your work.

MODE is one of the most eclectic DOS commands, controlling the operating mode of a variety of devices. To see the current operating statistics for the console, type:

MODE CON

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:

COLOR 1F

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.

0 = Black
1 = Blue
2 = Green
3 = Aqua
  4 = Red
5 = Purple
6 = Yellow
7 = White
  8 = Gray
9 = Light blue
A = Light green
B = Light aqua
  C = Light red
D = Light purple
E = Light yellow
F = Bright white

The order is always background first, then text color -- so COLOR 3B creates an aqua background with light aqua text, COLOR D0 creates a light purple background with black text and so on.

clear.gif

clear.gif
 
clear.gif
clear.gif

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.

Copyright © 2007 IDG Communications, Inc.

1 2 3 4 5 6 7 8 Page 8
Page 8 of 8
7 inconvenient truths about the hybrid work trend
Shop Tech Products at Amazon