Enhancing the Appearance of the MS-DOS Prompt WindowThis article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
by Gregory Shultz
Operating system: Windows 95/98If you're like most support professionals, you occasionally go to DOS to perform certain tasks. For example, when you need to rename groups of files you probably open an MS-DOS Prompt window and use the Ren command since you can only rename one file at a time in Windows Explorer or My Computer. As you know, going from the Windows graphical user interface to an MS-DOS Prompt window is a very abrupt change of environment, as the MS-DOS Prompt window is in black and white rather than color and the prompt is quite stark. However, it doesn't need to be that way. In this article, we'll show you how to add color to the MS-DOS Prompt window. We'll also show you how to spruce up the prompt a bit.
Adding colorReplacing the MS-DOS Prompt window's drab black and white color scheme with a more soothing color scheme is easy with our little technique. You simply create a short machine code listing, use Debug to compile the code into an executable file, and then link that file to the shortcut that launches the MS-DOS Prompt window. To begin, start Notepad and type the code shown in Listing A. Be sure to type the commands exactly as they appear--if you don't, the file won't work properly. (If typing in code isn't your forte, you can download the text file from our FTP site.) Listing A: This code creates a color scheme for the MS-DOS Prompt window.
After you type Q in the last line, be sure to press [Enter] to create a blank line at the end of the file. If you don't, the file won't compile correctly. Next, save the file as Color.asc in the \Windows\Command folder. As you save the file, be sure to enclose the filename in quotes or else Notepad will add the TXT extension to it. The line MOV BH,1F sets the color. In our example, the character combination 1F sets the color to bright white on a blue background. If you'd like to use a different color scheme, simply replace that character combination with one from Table A. Table A: Characters for setting color schemes
A 100 MOV AH,12 MOV BL,10 INT 10 MOV AX,0040 MOV DS,AX MOV AX,0600 MOV BH,1F SUB CX,CX MOV DH,18 CMP BL,10 JZ 011D MOV DH, MOV DL,[004A] DEC DL INT 10 MOV AH,02 MOV BH, SUB DX,DX INT 10 RET N COLOR.COM RCX 30 W Q
Assigning Color.com to the shortcutAt this point, you'll assign the Color.com file to the shortcut that launches the MS-DOS Prompt window. To do so, locate the MS-DOS Prompt shortcut on the Start menu, right-click on it, and select the Properties command from the shortcut menu. When the MS-DOS Prompt Properties dialog box appears, click on the Program tab and type Color.com in the Batch File text box, as shown in Figure A. To complete the procedure, click OK. Figure A: You'll link the Color.com file to the MS-DOS Prompt shortcut.
Now whenever you open an MS-DOS Prompt window, you'll have a more pleasant environment to work in. Keep in mind that if you happen to use the CLS command to clear the screen, you'll once again see the gray-on-black color scheme. Just type Color and press [Enter], and your color scheme reappears.
Enhancing the promptChanging the prompt that you see on the command line can add some pizzazz to the MS-DOS Prompt window as well. DOS stores the control string that defines the prompt in an environment variable appropriately named Prompt. You can take a look at the current prompt configuration by typing Set on the command line. When you do so you'll see a listing of the environment variables similar to the following:
There will be other commands in the listing, but we'll stop here because we're only interested in the Prompt environment variable. Because the prompt configuration is stored in an environment variable, the prompt is easy to change. To do so, you just use the Prompt=x command, where x is any supported parameter. For example, you can change the prompt from the C:\Windows> to the text string What? by typing the following at the command line:
TMP=C:\Windows\Temp TEMP=C:\Windows\Temp PROMPT=$p$g
In addition to text strings, the Prompt command accepts as parameters special metastrings. All metastrings for the Prompt command are two-character sequences that begin with the dollar sign ($). Furthermore, there are two classes of metastrings: static and dynamic. Table B lists the static metastrings that you can use in the Prompt command. Table B: Static metastrings
|$b||| (vertical bar)|
The static metastrings may look rather insignificant, but they're important because you can't use any of the characters that they represent in the Prompt command by themselves. We'll see this in a moment. The dynamic metastrings, which are listed in Table C, provide more interesting options. Let's take a closer look.
|$p||Drive and Folder|
This results in a prompt like the one shown in Figure B. As you can see this really provides more information than is necessary. You don't need the seconds or the hundredths of seconds. Figure B: This prompt shows the current time, the drive letter, and the current folder.
Prompt=$t $p $q$q$g
Fortunately, you can delete that information with six of the ([Backspace]) static metastrings--$h. The command then becomes as follows, which yields a prompt like the one shown in Figure C:
Figure C: This prompt eliminates the seconds and the hundredths of seconds from the current time display.
Prompt=$t$h$h$h$h$h$h $p $q$q$g
As you can see, this makes for a rather long prompt. Fortunately, you can use another Static metastring--$_ ([Enter])--to break your new prompt into two lines. The command then becomes the following, which yields a prompt like the one shown in Figure D:
Figure D: This prompt displays the time, drive and folder information on two lines.
Assigning the Prompt command to the shortcutSince the Batch File text box on the Program property sheet, as shown in Figure A, can only handle one command and the Color.com file is already assigned to it, you can't add the Prompt command there too. The solution is to create a batch file that contains both the Color.com and Prompt commands and then assign the batch file to the Batch File text box. To do so, launch Notepad and create the Enhance.bat batch file shown in Figure E. Then save it in the C:\Windows\System folder. Again, as you save the file, be sure to enclose the filename in quotes or else Notepad will add the TXT extension to it. In this batch file we run the Prompt command first, clear the screen with the Cls command, and then run the Color.com program. This sequence prepares the MS-DOS Prompt window perfectly. Now, access the Program property sheet and type Enhance.bat in the Batch File text box. Figure E: You'll create a batch file that contains both the Color.com and Prompt commands.
ConclusionGoing from the colorful graphical user interface of Windows to the stark black and white environment of the MS-DOS Prompt window can be a bit of a let down. In this article, we've shown you how to enhance the MS-DOS Prompt window with color and a more interesting prompt.
Copyright © 2001 Element K Content LLC. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Element K Content LLC is prohibited. Element K is a service mark of Element K LLC.