Build Your Skills: Tune your Windows 2000/NT and 9x/Me command prompts

Use these tweaks to make DOSKEY.COM, SET, DIR and other command prompts more user friendly.

If you frequently use your Windows 2000/NT command prompt (also called the MS-DOS prompt in Windows 9x/Me), a few enhancements will make your life easier. Throughout this Daily Drill Down, I’ll refer to the command prompt. However, all the examples I give work in an MS-DOS prompt as well, though the format may differ slightly.

External commands
Those of you who learned MS-DOS will remember that there were two types of commands, internal and external. Internal commands were loaded with, the MS-DOS command processor. External commands were .com or .exe files that were installed in your DOS directory and were pointed to in your Path statement. (We’ll come back to setting the Path below.) You can still find many of these useful commands installed in your Windows 9x/ Me \Windows\Command folder. In Windows 2000 and NT, they are stored in the \WINNT\System32 folder. All these programs can be run in your command prompt. Figure A shows the commands available to you.

Figure A
These command prompt executables are available in Windows.

If you frequently use the command prompt, one of the most helpful commands is DOSKEY.COM. DOSKEY.COM debuted with MS-DOS version 5.0. It stores your command line activity, allowing you to recall or edit commands entered during your session. This utility can save you a lot of retyping. To see how it works, open a command line, type DOSKEY, and press [ENTER]. Now type a few commands. For example, you might type IPCONFIG, then CD C:\WINNT\SYSTEM32 (or C:\WINDOWS\COMMAND), then DIR to see the contents of that folder.

When you’re back at a blank command prompt, repeatedly press your Up and Down arrow keys. Pressing these keys scrolls each of the commands you typed at the prompt ([F8] also scrolls through the commands). Now press [F7]. A list of all the commands stored in the buffer should appear with a number, as shown in Figure B. You can use your Up and Down arrow keys to scroll through this list and choose the command you want to enter. If you remember the number, you can use [F9] to enter it.

Figure B
Use [F7] to scroll through your command line activity and choose a command you want to repeat.

One useful command line switch is /LISTSIZE. This switch sets the number of commands that are stored in the buffer. For example, typing DOSKEY /LISTSIZE=30 remembers your last 30 commands. They will be numbered 0-29.

Activating DOSKEY in a command prompt works in that window only. Once you close the window, the next time you open a command prompt you’ll have to type DOSKEY again. In addition, you’ll have to retype it in each new command prompt. To avoid command line typing errors that make it frustrating to use a command prompt, you’ll want to make DOSKEY a permanent part of your command environment. I’ll show you how to do that below.

SET allows you to change your command environment. The SET command is internal, thus, it won’t appear in your directory listing. You can use it to modify the way the internal DIR command lists files and folders.

The well-known internal command DIR has a few command-line switches that make viewing files and directories more convenient. For a full list of switches, at the command prompt, type

You may remember that piping to the MORE command allows you to view the output of a command one screen at a time.

Among the switches you will see for DIR are /B, /O, and /P. The switch /B uses a bare format, listing one directory or filename per line. One undocumented feature of /B is that it displays long names, rather than the assigned 8.3 DOS names. I use /B to make viewing long filenames more convenient, as I have very little use for viewing truncated filenames such as APPLIC~1.

Using /O sorts your directory list. The default sort is alphabetical.

Finally, /P pauses the display after each screen of information. Press any key to see the next screen. To use DIR with these switches all at once, at the command prompt, type

Spaces are not necessary between switches, and you can use lowercase if you prefer. I’ve listed the typical output of DIR used with these three switches in Figure C.

Figure C
Modified output of the DIR command shows a sorted format and long filenames. Display halts at each screen.

After you’ve modified DIR once, you can use DOSKEY to repeat the command during your session. However, a special SET option, DIRCMD, lets you modify how DIR displays in the command environment. To modify the behavior of DIR for the entire session, at the command prompt, type

Should you decide you want to change your directory listing, you can temporarily turn off any switch by using the minus sign. For example, if at the command prompt you now typed DIR /-B, you would get the default file and directory listing, with truncated filenames on the left, long filenames on the right, and the date and size of files in between.

I’ll show you how to make your modified DIR output a permanent part of the command environment below.

Within a Command Prompt window, a prompt indicates that the system is ready for input. By default, your prompt shows the current drive and directory, followed by a greater-than sign, such as:

You may find it useful to modify the command prompt. You can do this using PROMPT, an internal command. To see the command line switches available for this option, at the command prompt, type

The available switches depend on your operating system. A few more are available in Windows 2000 and NT. Instead of using a forward slash (/), prompt options are preceded by a dollar sign ($). By default, PROMPT is set to display $P$G. ($P displays the current drive and directory; $G displays the greater-than sign.) Four other useful options are $L (displays the less-than sign), $V (displays the OS and version), $D (displays the date), and $T (displays the time). In addition, any ASCII characters you type after PROMPT will also be displayed. For example, to make my command prompt display my name, version of Windows, date, and current drive and directory, all separated by less-than and greater-than signs, I would type
PROMPT $LMike Jackman$G $L$V$G $L$D$G $P$G

My prompt would then change to
<Mike Jackman> <Microsoft Windows 2000 [Version 5.00.2195]> <Mon 01/22/2001> C:\WINNT>

I’m guessing that would be too much prompt for most people. Nevertheless, it illustrates how you can modify your prompt during a command prompt session. I’ll show you how to make your changes permanent in the next section.

Making your changes permanent
How you make your command prompt changes permanent depends on whether you are using an NT-based system or a Windows 9x-based system. In this section, I’ll give instructions for each.

Windows 2000 and NT
In Windows 2000 and Windows NT, you set the system environment in the System Properties app. Go to Start | Settings | Control Panel, and double-click the System icon. In Windows 2000, click the Advanced tab and then click the Environment Variables button. In Windows NT, click the Environment tab. You’ll see a screen similar to the one shown in Figure D.

Figure D
Change your command prompt environment in the System Properties utility.

In Windows NT, User Variables will be on the bottom and System Variables will be on the top. You can highlight a variable and click the Edit button to change it, or you can click the New button to add a variable. Note that in Windows NT, you don’t need to click a button, just type the variable and value in the spaces provided. Figure E shows how you would enter DOSKEY into your system environment. Note that DOSKEY.COM is the variable, and the value is /LISTSIZE=30. While it’s not necessary to add a value of /LISTSIZE for DOSKEY to work, by some quirk of Windows 2000, the environment list won’t display DOSKEY unless a value is entered. The same is not true for Windows NT.

Figure E
Enter new environment variables in the New System Variable box.

Once you click OK or, in Windows NT, hit [Enter], the new variables will appear in the System Variables list, in alphabetical order. Table 1 lists the variables and values I used in this Daily Drill Down.

Table 1
Variable Value
Command environment variables and values

Once you’ve entered the information, click OK to exit.

Windows 9x/Me
Windows 9x and Me call for a different approach to changing the behavior of your MS-DOS prompt. In Windows 98, you could modify your CONFIG.SYS and AUTOEXEC.BAT files directly, but it’s much more convenient to use the System Configuration utility. Choose Start | Programs | Accessories | System Tools and click on System Information. From the Microsoft System Information window, go to Tools, and from the drop-down list click on System Configuration Utility. A tabbed dialog opens. Click on the Config.sys tab and click the New button. A text box opens, allowing you to type information into your CONFIG.SYS file but in a much more controlled environment. In the text box, type:

When you press [Enter], a pencil icon appears to let you know a change was just made. If the check box to the left of your new entry isn’t checked, click it. Checking this box ensures the command is processed upon startup. Otherwise, it will be skipped. The ability to selectively choose which items are processed is what makes this such a valuable utility. Figure F shows the results of adding the DIRCMD variable to the Config.sys tab.

Figure F
Set the DIRCMD variable on the Config.sys tab.

Next, click on the Autoexec.bat tab. Using the same procedure, add the information for DOSKEY and PROMPT. When you enter DOSKEY, the switch /LISTSIZE is optional. The results are shown in Figure G.

Figure G
Add new DOSKEY and PROMPT values to the Autoexec.bat tab.

Click OK to exit. Your changes will take effect the next time you boot into Windows 98.

The procedure for Windows Me is nearly identical. Start the System Configuration Utility as described above. You’ll notice that the tabs are different. Microsoft designed Me to rely on DOS less than 98, though the change of emphasis is by no means extreme. Instead of a Config.sys or Autoexec.bat, you’ll see an Environment tab. Choose this tab, then click the New button. A window pops up with two boxes, one for entering a variable and one for entering a value, just as I described for Windows 2000 in the section above. When you’re finished entering your data, the results should look similar to Figure H.

Figure H
In Windows Me, make your changes in the Environment tab.

Click OK to exit. Your changes will take effect after you reboot your computer.
To learn how to create a shortcut key that starts your command prompt, read my Daily Feature “Use these keyboard shortcuts when your mouse dies.“For more information on ways to use the System Configuration Utility, read
In this Daily Drill Down, I showed you how to make your command prompt more useful using the external command DOSKEY.COM and the internal commands SET, DIR, and PROMPT. I also showed you how you can make these changes to your command environment permanent. Once you know how to set your command prompt, you can use any internal or external command available in Windows to make the time you spend typing at the command line less frustrating and more productive.
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Editor's Picks