(PC Magazine Vol 6 No 3 Feb 10, 1987 PC Tutor)
The most hassle-free method of getting some color on the DOS
command level is by using ANSI.SYS and the PROMPT command. The prompt
is the thing that normally looks like:
and the PROMPT command lets you change it.
ANSI.SYS is a device driver that comes with DOS. You can instruct
DOS to load ANSI.SYS by adding the following line in your CONFIG.SYS
If you don't have a CONFIG.SYS file, you can create one with EDLIN.
If you keep ANSI.SYS in a subdirectory (called DOS, for instance), the
line would read:
The next time you reboot, ANSI.SYS will be loaded. Now with ANSI.SYS
This gibberish creates a magenta prompt and yellow text on a blue
background. You can color the whole background blue by executing a
CLS command. If you're fond of that color combination, you can put
this line in your AUTOEXEC.BAT file in your root directory.
The ANSI.SYS device driver allows applications programs to control
the video display using control sequences standardized by the American
National Standards Institute (ANSI). PC applications programs that
actually use ANSI control sequences, however, are very rare. Most
applications programs control the display in other ways.
The ANSI.SYS control sequences are not documented in the DOS
manuals for Versions 2.1 or later. They can be found in the DOS
Technical Reference manual, however. The remainder of the DOS
Technical Reference is essential for assembly language programmers,
useful for other programmers, and a waste for people who don't need
(or want) to know about the internals of DOS.
All the ANSI control sequences begin with an escape character
(hexadecimal 1Bh) and a left bracket. The $e used in the PROMPT
command is the code that PROMPT uses for an escape character. The
control sequences to control color end with the letter m. Between the
left bracket and the m is a series of numbers separated by semicolons.
These numbers specify the color. They are:
Color Foreground Background
----- ---------- ----------
Black 30 40
Red 31 41
Green 32 42
Brown 33 43
Blue 34 44
Magenta 35 45
Cyan 36 46
White 37 47
A number 1 following a background and foreground number turns on
high intensity for the foreground. This is generally necessary for
text on a colored background. A high-intensity brown is yellow.
The $p$g in the PROMPT command is the non-ANSI part of the prompt.
As you can note from the documentation of PROMPT in the DOS manual,
this is a good prompt for a hard disk user, since it shows you both
the current drive and directory.
Another popular method for coloring the display uses BASIC. You
can create a small BASIC program (called, for instance, COLOR.BAS) that
10 COLOR 14,1
Then, when you execute:
you'll be back on the DOS command level with yellow text on a blue
background. (The color codes used in BASIC are documented in the BASIC
manual under the COLOR statement. Naturally, they are entirely
different from the ANSI.SYS color codes.) You could put the line
BASICA COLOR in a batch file called C.BAT. Then, just executing C
will set your colors.
The ANSI and PROMPT method is a little more complex at first, but
once done you don't have to fuss with it. Many applications programs
reset the video mode and clear the screen when they start up. So,
after you get out of these programs, you'd have to execute the COLOR
program again. With the ANSI and PROMPT method, you don't have to do
If you use the BASIC program rather than the PROMPT command for
setting your colors, do not load ANSI.SYS. ANSI.SYS will use its
default color values (gray on black) instead of those that BASIC sets.
Fast Screen Colors
(PC World February 1987 Star-Dot-Star)
SCREEN.BAT uses 16 IFs (and no GOTOs) to set screen colors at the
DOS level. GOTO statements slow batch file execution because the
command processor always starts at the beginning of the batch file
when searching for a label.
echo Changing colors ....
if %1!==black! set fgc=0
if %1!==red! set fgc=1
if %1!==green! set fgc=2
if %1!==yellow! set fgc=3
if %1!==blue! set fgc=4
if %1!==magenta! set fgc=5
if %1!==cyan! set fgc=6
if %1!==white! set fgc=7
if %2!==black! set bgc=0
if %2!==red! set bgc=1
if %2!==green! set bgc=2
if %2!==yellow! set bgc=3
if %2!==blue! set bgc=4
if %2!==magenta! set bgc=5
if %2!==cyan! set bgc=6
if %2!==white! set bgc=7
echo New colors now in effect