There are not many commands you need to learn in DOS to use it effectively, but you do need to learn how to get "syntax" help. Originally there was (and currently is) a HELP facility which is itself a command: help. Some versions of Windows do not automatically install the Help command, however (Windows 95, for example).
Each command has a mini-help facility within it, which is activated by adding just the parameter /? (forward slash, question mark) to the command. But truly, typing help commandname is better because it has a far smaller possibility of error -- do you really want to type del /? or does help del feel safer? A mistype, for example missing the forward slash (del ?) will delete every file in the current directory that has a name one character long (with no extension). Mistyping the forward slash as a back slash (del \?) will delete everything in the root directory which is one character long. Granted, not too many files are like that, but they certainly can be. "A" is a legal filename. And Windows doesn't save files to the recycle bin that are deleted while in DOS mode! And formerly popular DOS programs that might have helped you undelete DOS files are now usually not recommended for Windows 95 machines (after that, I haven't checked...). As far as I know, if you delete a file in DOS these days -- it's gone. So by all means delete when necessary, but always delete with care.
The first command you need to learn to use DOS is simply how to get help. Unbelievably, with Windows 95, Microsoft stopped automatically loading the MS-DOS HELP facility when you install Windows. This is the most important DOS command of all and yet Microsoft choose not to load it automatically when Windows is installed.
Fortunately, HELP is back, and in the meantime, Microsoft also completely instituted the command-by-command help standards, so you can simply type the command name and the add the two symbols /? (forward slash, question mark) after the command. Some commands take more than one page to see; use the pipeline command MORE (|more) to view the screens one at a time.
(Note: If you are (for some reason) running Windows 95, you can load the DOS HELP from the Windows CD-ROM. It is in the \OTHER\OLDMSDOS directory. You need to load QBASIC.EXE, QBASIC.HLP, HELP.HLP, and HELP.COM. They can be placed in the \WINDOWS\SYSTEM directory. Placing them there makes them immediately available again to DOS users.
This command gives you a key to virtually everything you need to use DOS effectively. Can't remember the format for the FORMAT command? Not a problem! Type HELP FORMAT and press the ENTER key, and you've got everything you need to use FORMAT! This is true for virtually every DOS command so if you remember HELP commandname you won't have any problems.
Another way to get help (or, if you don't install the HELP files suggest above, the ONLY way to get help in Windows 95) is to use /? (slash, question mark) after any command. This is faster and sometimes a more useful form of help, but it is generally only a listing of options. HELP is usually a more verbose help facility than /? is.
Once you know where to get help, the rest is easy. The whole purpose of DOS is to let you get around the directory tree easily. You use DOS to start applications (like my own P11.EXE program) and to copy files, delete files, build places to put files, and compare files, and so on. Files, Files, Files. That's what DOS is really for.
The #1 tool for file handling is the COPY command. Specify the "from" file first, then the "to" file. COPY only copies from within one directory at a time, but the "to" directory can be different. For copying entire diretory structures, use XCOPY instead.
What makes COPY so powerful is that you can use "wildcards" like * and ? within the filename.
Like COPY, XCOPY can use wildcards to copy a file or group of files to another directory. But XCOPY is more powerful because it has the ability to copy an entire directory structure in one command. Use the /s option to accomplish this. Use HELP XCOPY to learn more, of course!
CD is the cold, hard way of doing things, but sometimes it's the right way. What makes it cold and hard is that in comparison to Norton's Change Directory (normally abbreviated NCD, but I abbreviated it to C on my system), the DOS CD command requires you to type the complete directory entry, all the way back to the root level! This is absurd. NCD, on the other hand, lets you type in anything that's close, and it will search your entire directory structure and plop you down right where you want to be. For example, to go to the \p11\pumps\svgapump directory, I can just type in: c svgap and immediately NCD will take me there. With CD, I would have to type cd \p11\pumps\svgapump to accomplish the same thing. Saving keystrokes is the name of the game. (That's why later in this tutorial, you'll learn to write batch files.)
MD will make a new directory. You can specify the entire directory structure or just the new part, if you are already in the parent of the new part. Got that? I didn't think so. Let's say you have a directory called \animals. Let's say you are in that directory, having typed cd\animals at some point. To create the directory \dogs as a subdirectory of \animals, you can type in md dogs when you are in the \animals directory. Or, you can type in the full md \animals\dogs from any directory. However, you can't make two directory structures at once. \animals must exist before you can use MD to create \dogs.
CD and MD (and RD) are often used in conjunction with each other. If you use MD to make a new directory, to then go into that new directory, all you should have to do is just back up the command stack one command and change the M in MD to a C. (That's why you need a command stack manipulator like CED. In plain DOS, Function Key 3 will give you the last command, but only the last command. CED will go back dozens of commands.)
It's very important to understand a principal brought up in the last paragraph--that you never retype anything you don't have to. Don't be fooled into thinking it's easier to retype than to find the old command in the command stack and change a letter. First of all, it isn't. And second of all, when you get to the DELETE (DEL) command, you really need to not retype things! (read on...)
When you empty a directory and wish to remove it entirely, you can use RD. RD will not delete the entries (files) in a directory. They must already be deleted (the directory must be empty) for RD to work. However, these two steps can be simplified by doing them in order. Use the DEL command (described below) and then bring the command line back (using your command stack manipulator). Change DEL to RD and a space character. That way, you can be sure that you will remove the exact directory you just emptied, because you don't retype the directory name. Actually, it's normally a three-step process, since you would normally start with DIR filename, then change DIR to DEL filename, and then change DEL to RD and a space.
For example, to remove the contents from the directory BARNEY and then remove BARNEY, use the following three commands. Bring them back each time with your command stack manipulator, and just change DIR to DEL and then DEL to RD and a space:
You could, in theory, also use the command DELTREE to remove both the contents and the directory. You could, but you should refrain from doing that, because DELTREE is a dangerous command and should be used slowly, carefully, and sparingly. It should be a special occasion to use DELTREE, but RD is an everyday thing.
DIR is the DOS way of getting a listing of a directory. Incredibly weak, it nevertheless has the advantage of being exactly like DEL in the way it handles wildcards and directories. Therefore, you can type in DIR *.txt, and it will list all the files that end with an extention of .txt, and after you see that that's what you want, you can change the DIR to DEL after retrieving the command back, and you know that you'll delete only what you want. And save keystrokes too!
REN is short for RENAME. You can rename any file or files to any valid, unused name(s). Wildcards work fine. You could rename a file by first copying it and then deleting the original, but this means you would use the more dangerous DEL command. Never use DEL if you don't have to! REN gives you a way not to use DEL. As an added benefit, REN is faster than COPY/DEL, especially if it's a big file or group of files.
DEL is the electronic equivalent of a paper shredder. The only way to recover files you have accidentally DEL'ed to death is with some complicated software program that MIGHT or MIGHT NOT work, but then again it might give you new gibberish. And if you DEL'ed star-dot-star (*.*) you can pretty much forget most UNDELETE software programs from succeeding. Think of DEL as short for DISASTER IF I DIDN'T MEAN THIS.
That being said, of course, DEL is the standard way of deleting things. But because it's so final, you should almost always use DIR before you use DEL. Here's the plan: first, use DIR to view the filenames you wish to delete. Next, use your command-line buffer to get the same command back, and type DEL over DIR. That way, you will be absolutely sure that you will only DEL the things you just looked at with DIR. It's faster too, usually, than retyping the thing you want to delete. But even if it weren't, this is the best way to delete things.
By the way, whenever you type in DEL *.*, you should always take your hands away from the keyboard and review what you are doing. Are you on the right drive and in the right directory? Do you really want to do this? Same is true for any DEL command with wildcards, at least pause for a second or two, especially since the file recovery programs I mentioned work much more reliably if you just need to recover a single file, but if you need to recover multiple files, they are much less successful.
DELTREE is brutal and can really mess you up. Its power is of course, its virtue. With DELTREE you essentially combine the DEL *.* command with the RD command, but it's even better because you can delete all the subdirectories as well, all in one swoop. Definitely this is a good command to know and respect. ALWAYS pause before hitting the ENTER key with this command! I literally take my hands away from the keyboard and read the line before I press ENTER when I use this command!
FC is short for FILECOMP, or FILE COMPARE. You should always use this command to compare files that are really important to you when you create a new copy. If you duplicate software, use FC to be sure that the "masters" for the manufacturer or distributor are the same as your own masters. FC takes too long, and systems are too reliable, to use it all the time, for everything. Besides, when copying files on your hard disk this command is not usually needed because a similar command takes its place: In your AUTOEXEC.BAT file the command VERIFY=ON. VERIFY will normally cause DOS to read back every file it writes, every time it writes it. At least, that's what it's designed to do, but whether VERIFY always does that, with every file, on every drive, well--I'm skeptical. So I use FC when it really matters.
DISKCOPY lets you make exact copies of master diskettes. This is good for backup and small distribution purposes. If you use DISKCOPY to copy a diskette to another diskette using the same physical disk drive, then DOS will copy a piece at a time, and will prompt you to swap them back and forth until it's done. Somehow, Microsoft hasn't thought of using swap space on the hard drive so you would only have to swap the physical media once. Maybe some day it will occur to them. There are shareware and other tools to do multi-disk copies, which do use "image files" on disk, for larger runs. Beyond a few hundred copies, consider a CD master or outside disk duplicator service.
When you make a "MASTER BACKUP" disk of something really important, you should use DISKCOMP to be sure it is the same as the "ORIGINAL MASTER" diskette.
EDIT is a fairly lousy editor. My actual ASCII text editor of choice was an early version of BRIEF which I used for almost everything. BRIEF was text-based and the only real problem was, everyone agrees I could have used a spell-checker if it had one but hey--it was fast. And it was great for writing batch files, something you'll be introduced to later in this document. (Note: As of 1997, I moved to Boxer/TKO from David Hamel. It's everything BRIEF was, and much, much more! (Note: As of 2007, Brief does not appear to be available anymore, and I no longer do anything in DOS, so I don't use Boxer, either.))
But for those without an ASCII text editor of choice, we all have EDIT available to us from Microsoft. It beats the pants off of the old EDLIN, but if you remember EDLIN, you probably wouldn't need to be reading this.
EDIT is for writing batch files, and for editing batch files. That's about all it's good for, but you'll probably find youself using it often enough that you should get comfortable with it. Know how to delete a line, how to move around the document, how to insert and change characters, and how to copy a section. Just know how to get help in EDIT and then remember to use it when you need it. (F1 is the help key in EDIT, by the way.)
A lot of problems with running programs in DOS has to do with memory, same as in Windows and just about everything else, I guess. Many programs (including ours) tell you what amount of Conventional memory and what amount of Expanded and/or Extended memory they need.
Knowing these values, you can use MEM to see if you indeed have enough memory available to run your application.
Use MEM /c|more to get more information, and have it scroll a page at a time. (See memmaker, below, to learn what to do if MEM turns up showing too little memory available.)
NOTE: As of Windows 95, Microsoft no longer seems to use Memmaker.
When MEM, above, reports that you don't have enough Conventional Memory, Expanded Memory, or Extended Memory, you can use MEMMAKER to (hopefully) free some memory up.
MEMMAKER is a Microsoft program that tries to place programs which are in Conventional memory somewhere else--who cares where, right? Usually it's in a place called HIGH MEMORY, or UPPER MEMORY. DOS can actually directly access one megabyte plus 64K of memory, but unfortunately useless screen modes take about 30% of that area. MEMMAKER can make more Conventional memory available by filling in some nooks and crannies in the total addressable 1 meg+64K area.
FORMAT should be used for diskettes only. You virtually never want to FORMAT your hard drive. If you did, you'd probably start with a low-level format "just to be on the safe side" anyway. FORMAT is for diskettes only! So, NORTON came up with a nice program called SF (SAFE FORMAT) which will replace FORMAT and which will not allow you to accidentally format your hard drive. I use SF instead of FORMAT, but if you use format, you can still get the safety aspects of SF by renaming FORMAT.COM and then creating a batch file called FORMAT.BAT and placing it in the C:\DOS directory. The batch file uses the batch file command IF to only allow you to use A: or B: or a: or b:. All other "options" are invalid.
PROMPT is a little thing, but you need it. The "infamous DOS
prompt" can be greatly improved. I use:
This goes in your AUTOEXEC.BAT file and will, as shown, cause DOS to display a prompt consisting of the day of the week, the date, the time to the second, the drive and current directory, and a greater-than sign. I like it that way. Knowledge is power, you know.
Redirection (> and <, greater-than and less-than signs) allows you to send
(>) output of other commands somewhere else, or receive (<) input from somewhere
else. Output is often sent to a file instead of to the screen with this option.
For example to send the output of a DIR command to a file called mydir.txt, use
This would take the output of the DIR command and place it in a file called mydir.txt instead of displaying it on the screen. Use two greater-than signs (>>) to append to an existing file. You can also send output directly to the printer using the special destination name prn (or prn:).
To receive input from a file rather than from the keyboard, use < and then the name of the file which has the input lines that you want to use.
Piping takes the complete output of
one command and sends it to the next command (after the vertical bar). Pipes are
useful for many things, but probably the most common use of pipes are with the
more command to cause the output of other DOS commands to be displayed
on the screen one screen at a time. For example:
MORE will display the piped output of the mem command to the screen and when each screen full of information appears, MORE will wait for a keypress before displaying the next screen.
Batch Files are such simple timesavers that you'll want to be able to write and edit them yourself.
To learn to write batch files, you can download any of our demos, all of which have simple batch files to start them, and copy the code for them. It's pretty easy. Use EDIT to create batch files you need to accomplish things you do more than once or twice, or to develop series of commands you want to execute repeatedly.
Batch files don't have to be big -- I have plenty of one-line batch files which I give short names to and which might only execute one thing. Batch files can call other batch files or jump to other batch files, which increases their usefulness substantially.
Batch files are time savers and they help you to do things quickly and efficiently and the same way every time.
In order to save keystrokes, I often rename the few programs I use regularly, like BRIEF.EXE which is renamed b.exe and placed on my virtual drive for virtually instant access. (Note: as of 1997, I now use BOXER by David R. Hamel, which is started with the initials TKO. Also, like many people, I have finally made the complete switch to Windows 95 as the base operating system on the computer, and no longer make use of a virtual drive for my individual DOS sessions (since they would take too long to set up each time, and hard drives are much faster.)
Here are some brief descriptions of IF, GOTO, and SHIFT.
Note that these are specific to DOS batch files, and are not used at the command line. Also, note that both IF and SHIFT involve the variables that are available in DOS, namely %0 through %9. They contain the items between the spaces following the batch file name on the command line. For example, a DOS command line might read:
In this example there are two variables after the batch file name (RUNPRGMS.BAT).
%0 would be equal to GENI. %1 would be equal to MCGA. In a batch file, you could put the following line to use the first two variables:
The command line which the executible program (P11RUN.EXE) gets would depend on the values of %0 and %1 at the time. Each parameter substitution would be separated by single spaces.
IF used in a batch file compares something on the left of a double equal sign ( == ) with something on the right. So if the thing on the left is %0 and the thing on the right is %1, then IF %0==GENI would be TRUE in the above example (the evaluator is case sensitive), and the operation that would follow it would be executed. That might be GOTO, which can follow an IF comparison, or it might be SHIFT, or many other things. You can also use IF NOT... In addition to comparing variables (strings), you can compare the ERRORLEVEL number, or do an EXIST of a file name.
It's often a good idea to check for a null variable separately.
This is done by doing something like this:
This will jump immediately to a label name -- but note: ONLY the first 8 characters are significant, and the first character is a : (colon), and I don't know if it's counted as one of the eight significant characters. Labels can be ahead or behind the GOTO, that is, anywhere else in the batch file.
This batch file command would cause the batch
file interpreter to skip forward to the named location. Locations are named with
a colon in front:
This batch file command will shift variable %1 into variable %0, variable %2 to variable %1, variable %3 to variable %2, variable %5 to variable %4, and so on through %9. I'm not sure what happens to %9, I think it's eliminated after its value has been being moved to variable %8 (you might want to run a test to be sure of what happens) unless there were more parameters to begin with which DOS can use to fill the 10th slot, in which case, it will move a new value in. There are no parameters to the SHIFT command.
or some other DOS command stack manipulator.
I used CED for a long time. Another popular command stacker is called DOSKEY, for both MS-DOS and PC-DOS. The purpose of a command stack manipulator is to let you get at previous DOS commands you typed without having to retype them. Again, plain DOS only lets you get at the very last one, which is sort of like having Alzheimer's disease. Unfortunately, if you tend to use DOS or the DOS emulator from within Windows, repeatedly running new sessions of DOS, a command stacker won't help much, because each session is completely separate.
or some other 'advanced' directory file viewer
DIR is too simple, and has no color. HDIR provides a much easier way to display a list of files in a directory and the list is much easier to read than a DIR output. There are many other similar tools. If you use HDIR, use CED's cedparms to rename HDIR as H, and put HDIR in a root directory or better yet, on a virtual drive for fast access.
or some other Change Directory tool
Norton's NCD is good, but again, use CED to change the name to C instead of NCD, and put it on a virtual drive on your system.
Norton's FF (FileFind) is good, so if you have Norton Utilities, you might as well use FF. But there are a number of shareware tools that are just as good or better. You need to be able to find any file you know the name of (or part of the name) anywhere on a disk, or even across multiple disks. You should also be able to find files with similar names so you can delete old duplicates and old work-in-progress files.
To actually use DOS properly, you have to have a few tools to go with it. DOS as installed by Microsoft is virtually crippled and very difficult to use.
Several companies supply the necessary tools. Some of them are free. The tools I use are not the only choices, but they are the ones listed below the list of commands, and they are each desribed below the list of command descriptions.
The thing about DOS is how quickly you can get things done. Fewer keystrokes. It's textual, and it's fast. But to be really fast and easy, it needs some help. For some reason Microsoft won't add a previous-commands buffer to DOS! (They store only the last command.) And their official policy on ced, the one I prefer, is that it doesn't work with WINDOWS. But I don't know of a better command line retrieval system the ced. CED is a good program. Microsoft should make WINDOWS work with it, or they should at least fix DOS to emulate its general capabilities.
Someone once asked me: "Will you teach me DOS?"
So I wrote this.
This is 1996 (updated a bit in 1998 and again in 2001 (and even again, in 2010...) as I write this, and not everyone knows DOS anymore. (2010: Make that "hardly anyone has even heard of DOS these days..."). But DOS is easy to learn (2010: if you're a geek who likes to torment themselves) and it is a great way to get things done in life! (2010: ditto)
Of course, our own "P11" program and all its applications ran in DOS so we wanted people to be at least a little comfortable with it. Hence this document.
DOS is considered the bad guy, especially by people at Microsoft, who 'dis' it more than anybody, and so people are naturally a little afraid of DOS. Some people think WINDOWS is better than DOS simply because it isn't DOS.
But the beauty of DOS from a user's standpoint is that it is fast and easy to work with. The beauty from a developer's standpoint is that it allows me to easily control the entire PC hardware and virtually all of its timing capabilities.
I hope this little guide to vital DOS commands and tools will convince you that DOS is alive and well, and just dandy for all sorts of things. Please email me and let me know if it did you any good!
Many thanks to those who have offered suggestions for improving this little tome, and to the hundreds who have written letters of appreciation.