Martin Walker dons his white lab coat and explains the advantages of knowing a little more about DOS and the Command Line Interface.
Before you turn the page to avoid being accused of being a closet anorak, spare a few moments to find out why having a basic knowledge of DOS commands could help you. Many people buying PCs nowadays are almost unaware of DOS (the Disk Operating System), since it is normally bypassed when loading Windows 95. However, it's still there underneath, and knowing how to find your way around in the murky world of the Command Line Interface (CLI) may one day enable you to launch a disk fixer program if you ever get problems with your hard drive, or manually put right some tricky problem that prevents Windows 95 from appearing on your screen.
Windows 95 has largely removed the need to do anything but 'point and click'. You could think of Windows as like using the lift in a large office building — you decide where you want to go, press the appropriate buttons, and then the 'behind the scenes' machinery whirs into action. Normally, when Windows 95 is up and running, you also use the lift, since pressing a single button will get you where you want to go. However, if the lift breaks down the only solution is to use the stairs, and take things a step at a time. Each step is the equivalent of a single DOS command.
Anyone who has ever seen a computer terminal as used in a feature film will know at once what to expect from DOS — close‑ups of frantic tapping on the keyboard, followed by pressing the Return key. In the world of Hollywood, this always results in wonderful screens full of text and numbers scrolling into view, while everyone looks on with suitably enigmatic expressions and pretends to understand what's going on. Still, it's a fairly accurate representation of DOS.
When in DOS mode, you still have full control of all basic functions, such as the launching of programs, and all aspects of file management. However, instead of the point and click interface that we now take for granted (more accurately known as the GUI, or Graphic User Interface), DOS uses a Command Line Interface (CLI). This is so named because each command is entered as a single line of text, after which you press the Return key (an abbreviation of Line Return, much like the carriage return of a typewriter) to carry it out.
DOS was first introduced way back in 1981, when few personal computers possessed hard disks, and floppy disks were really floppy and of the 5.25‑inch variety.
The core of available commands is contained in a single file named COMMAND.COM, which you will still find on every PC today, and this is loaded into memory during the boot‑up process. The reason why DOS can carry on when Windows is falling about your ears is that once the PC has finished booting up to the CLI, the contents of this single file, and the code inside the BIOS chip, are all that is needed for the majority of simple commands. There are no conflicts with the hundreds of additional files which get involved when Windows is running. Sometimes, when there are conflicts within Windows which prevent it from booting up properly, going into DOS to run a utility or carry out some basic maintenance work is the only way to sort out the problem.
If you run the 'MS‑DOS Prompt' from the desktop or Start Menu, you're actually running DOS in a separate window, and Windows 95 is still lurking in the background, like some over‑zealous nanny. If you need to get back to Windows 95 from inside a DOS window, the command to do this is EXIT (type 'EXIT', and then press the Return key). If you want to switch from being in a window to full‑screen immersion, press and hold the Alt key, and then use Return to switch between the two screen modes. This may take a few seconds if you have a multisync monitor. However, even if the DOS window is maximised in this way, the rest of the Windows 95 graphical interface is still there, beneath the surface.
To enter the unfettered world of stand‑alone DOS, press the F8 key when booting your PC (when you see the 'Starting Windows 95' message), and choose the 'Command Prompt only' option. You could also choose 'Restart Computer in MS‑DOS Mode' from the menu that appears when you're about to shut down Windows before switching your PC off. Both these actions will cause Windows support to be entirely removed. If you're in stand‑alone MS‑DOS mode, and not yet running Windows at all, you can type WIN to start it up.
Before we go any further, one potential source of confusion needs to be explained. Although Windows refers to files being placed in 'folders' (to extend the visual analogy for its graphical interface), DOS refers to these as 'directories' (as in Directory Enquiries). These two terms are synonymous. It should now be more obvious why the DOS command to show the contents of the current part of the drive is DIR (Directory). If you can't wait to try something, nip into a DOS window by clicking on the MS‑DOS Prompt option on the Start menu, and type 'DIR', then press the Return key. Easy, isn't it? (note that, with all the DOS commands I'm about to cover, you don't have to type in the single quote marks you see on the page here. They're just to differentiate the commands from the rest of the text.)
If you're in a large directory, screens full of data will flash by. That's what Hollywood thinks computers should do, but it doesn't make it very easy to find a particular file. If you're very quick, you can use the Pause key (above the cursor keys) or Ctrl+S (hold the Ctrl key and then press S) at exactly the desired moment, to stop the screen from scrolling any more, and then press any other key to resume. If you want to escape from a vast scrolling morass of files, use Ctrl+C, or Ctrl+Break.
Most DOS commands have a help feature, which you can access by typing the command, followed by ' /?'. For instance, to see all the options available for viewing the contents of the current directory, type 'DIR /?' (with a space between the two parts). Although the resulting page looks complex, there are two options that I often use. The '/O' option sorts the files into alphabetical order before displaying them, which makes finding a particular one far easier, and the '/P' option pauses after each screen full of entries, to give you time to read them (pressing any key continues to the next screen). So typing 'DIR /O/P' will give you neatly ordered screens full of files — much easier. Later on, we will see how you can automate this by modifying a batch file.
If you're trying to locate a particular file, which, for instance, starts with the letters MSD, typing 'DIR /S MSD*' will not only look in the current directory for all files starting with these letters, but will also (because of the /S) look in all sub‑directories (inside the current one). The 'star' symbol (above the '8' key) is known as a wild card, since it ignores anything after the fixed filename that precedes it — so it will find files such as MSDRAW.EXE and MSDOS.SYS, as well as the desired MSD.EXE. The same system applies to Windows 95 programs like 'Find'.
Now that we know how to view the contents of a directory, we need to be able to move from one to another. This is done using the CHDIR (Change Directory) command, or the more usual shortened form 'CD'. CD followed by a name will take you to a particular directory, so 'CD WINDOWS', for example, would move you to the WINDOWS directory. To move up to the next directory in the hierarchy, type 'CD..' (two dots), and to move up two directories in the chain, type 'CD...' (three dots). To move right back to the root directory (so that you are no longer inside any sub‑directories), type 'CD \' (the backslash symbol is on the key immediately to the left of the Z key). If you want to search the entire hard drive for particular files, first get to the root directory using 'CD \', and then use the DIR command with the /S option, as previously mentioned. So, for instance, to find every single MIDI file on your drive, you type 'DIR /S *.MID'.
Finally, to change to another drive altogether, type the drive letter followed by a colon. If your CD‑ROM drive is normally drive 'D', you would type 'D:', whereupon the prompt would change to indicate that you were viewing the contents of this new drive. Remember that, if all else fails, once you have CD‑ROM support you can completely re‑install Windows 95 from DOS by moving to the CD‑ROM drive, and then typing SETUP, if you can't get Windows to run normally.
Sometimes, when there are conflicts within Windows which prevent it booting up properly, going into DOS to run a utility or carry out some basic maintenance work is the only way to sort out the problem.
Incidentally, only Windows 95 allows filenames longer than the '8 + 3' standard. Both DOS and Windows 3.1 stick to a standard layout for filenames: an initial name up to eight letters or digits long, followed by a dot, and then an 'extender' of up to three letters or digits, which distinguishes different types of file, such as .MID for MIDI files, and .TXT for text files. Although Windows 95 allows much longer filenames to be used, these will be truncated to eight letters or digits when you are in DOS, so that, for instance, the 'Program Files' folder of Win 95 will appear in DOS as PROGRA~1. This does make moving around a bit harder, because if you want to get inside this directory you have to type the truncated name as DOS shows it, rather than the full name you know and love. However, DOS is impervious to whether you type in upper or lower case, which does save a bit of time.
Over the years, various conventions have evolved: the floppy disk drive is always A: (and this is the drive that the PC will normally attempt to boot from, before trying the hard drive); the B: device is still reserved for a second floppy drive; and the C: drive is normally your main hard drive. Any additional drives are allocated drive letters on a 'first come, first served' basis. It is perfectly possible to have up to 26 drives in total, with each being given a unique letter of the alphabet. So, if you want to see what's on a floppy disk, either type 'A:' to change to this drive, and then 'DIR' to see its contents, or type 'DIR A:' to combine both operations into a single command, which will show you the contents, but still leave you on the original drive. Using these basic commands, you can look for files in any directory on any drive, which you might well need to do to find and start a DOS program when Windows is proving troublesome.
In 1997, with Windows 95, and most people running at least 16Mb of memory and a minimum of a 1Gb hard disk, DOS is still there, and its little flashing C:> prompt is still available to those who need it.
The PATcommand will show you which directories are automatically searched if you want to start another program. When you want to start a program or use a command, you can simply type in its name and press Return, but unless DOS finds it in any of the directories included in the current PATH, you will get a 'Bad Command or Filename' error message. Normally, the directories included are WINDOWS, and WINDOWS\COMMAND. If you need to start a program that is not in either of these directories, you must either use 'CD' to first move to the directory in which the program is stored, or change the PATso that this additional directory is included in the search path.
There are two types of DOS files you can run from the CLI, and which contain programs. Files ending in .COM are commands. COMMAND.COM contains many of the simpler commands in a single file, but there are many others, such as FORMAT.COM, which carry out one specific function. Those files ending in .EXE are executable files (explaining the difference would involve a long discussion of the limitations of running files in a single 64K memory segment, so don't ask). To start any DOS program, simply type the name of the program without the extender (the bit after the '.'). So to start the Microsoft Diagnostics Program (MSD.EXE) you type MSD followed by Return (you will probably need to do a 'CD\WINDOWS\SYSTEM' to get into the correct directory first).
Although I have so far only mentioned text commands, it is perfectly possible for a DOS program to use graphics, and indeed there are DOS programs available that mimic the Windows 95 'look' so perfectly that many people may be totally unaware that they are not actually running a Windows 95 program. Partition Magic is one such program (see Figure 5). Since it enables you to create and change the size of partitions on your hard disk (see review in April 97 issue) it has to be run from DOS, since the Windows 95 files will probably themselves need moving. The huge advantage of a DOS program is that it is totally self‑contained, and does not need an arsenal of .DLL and other Windows System files to function properly. Since DOS programs nowadays are mostly run in times of crisis, the cosmetic graphics are normally the first to go, so that the program remains small enough to fit on a floppy disk. However, even programs such as Microsoft's Diagnostics, which use a blocky style of graphics that take only a tiny amount of memory, can still provide mouse support, and this certainly makes life easier for electronic rodent enthusiasts.
Batch files are simply small lists of DOS commands which are carried out one after the other, and whose filenames end in '.BAT'. Their main use was (and still is) to automate frequently used series of commands, which saves lots of typing. Before Windows came along, nearly all setup and install programs were batch files. Once the sequence of individual commands has been typed into a simple text editor program (such as Notepad in Windows 95), the resulting file is saved as NAME.BAT, where NAME is any meaningful eight‑letter or eight‑number filename. Then, to carry out the commands, you simply type 'NAME' and press the return key. Since each line in these files is a single command, you can often achieve the same result by typing each line manually in turn and then pressing the Return key. There are, however, a few special commands that can only be used in batch files, and not through the CLI (all are documented in the Windows 95 file shown in Figure 1).
During the PC boot‑up procedure, two such files are processed: AUTOEXEC.BAT, and a special file called CONFIG.SYS (a system file) which also acts in a similar way (who said Microsoft can't change its own rules?). Anyone who has been following my contributions to the PC Musician section of this magazine will have come across these files several times before, as they can be a vital part of your setup. Although CONFIG.SYS is not always needed by Windows 95, there are two main reasons for its presence: to provide drivers (small programs that are the glue between hardware and operating system) for any rare device that has no Windows 95 driver, and to supply drivers that may be needed when running DOS by itself, without the safety net of Windows 95. As we saw last month when installing a new hard drive, you may not be able to access your CD‑ROM when outside Windows — this is a prime reason for a DOS driver to be loaded using the CONFIG.SYS file.
It's likely that the only time you will need to alter the contents of these two small files is when trying to solve hardware problems, especially after installing new hardware that insists on adding all sorts of extra lines to these files 'behind your back', during the installation. One of the main reasons why you might need to modify such a file is to add or remove a reference to a driver or other program (often related to soundcard operation). Sometimes when you're updating drivers, or installing new hardware, a text file will pop up to give details of any such manual changes required, although most installation procedures nowadays are completely automatic.
In the case of a piece of problem hardware, you may need to temporarily stop a driver from being loaded, to check that it is not the cause of the problem. If a README file that came with an application suggests temporarily disabling a driver to see if it is the cause of a problem, the easiest way to do this is to type in a 'Remark' command at the beginning of the appropriate line in the file. The abbreviation for this is 'REM', and adding these three letters will turn the entire line into a remark (often used in the old days to add a comment explaining what the hell the following set of commands were supposed to do!). The act of adding this command became commonly known as 'remming', so that to stop the command line being processed you simply 'remmed' it out. Batch files can also be customised by removing lines, or adding extra ones, to set things up exactly as you like them. If you look at Figure 3 you will see a highlighted line, 'SET DIRCMD=/O/P', and I have added this in my AUTOEXEC.BAT file, so that whenever I go into DOS, all directory listings are alphabetically sorted and presented in neat screenfuls.
Many of the entries in these two setup files are now largely redundant if you have Windows 95 installed on your PC, since there are more sensible default settings, and few people use DOS by itself. It is perfectly possible to bypass these files altogether in many cases, if you don't run any DOS‑only programs such as games. You can try this by temporarily renaming the two files to something like AUTOEXEC.BA$ and CONFIG.SY$, and then re‑booting. If no problems arise from this, you will have saved a little booting time on a permanent basis. Their main use (to me anyway) is when they appear on the floppy startup disk, and load DOS drivers, for CD‑ROM drives, for example (see last month's feature on installing a new hard drive). If anything untoward happens, simply rename them and re‑boot once more.
If you need to do some simple editing from DOS, there's a nice little program called EDIT (EDIT.COM, normally found in the WINDOWS\COMMAND directory) that's fine for basic tweaks. It also features full mouse support and Windows‑like drop‑down menus, and has its own DOS‑style help file. Any amendments to your startup files can easily be carried out from here. Even if you have no intention of doing any editing, it's also a useful way to look at the contents of any drive, since its File Open dialogue box acts very much like the typical Windows equivalent, allowing you to whizz around the drive without typing anything in at all.
In 1997, with Windows 95, and most people running at least 16Mb of memory and a minimum of a 1Gb hard disk, DOS is still there, and its little flashing C:> prompt is still available to those who need it. I don't think that anyone, except a few die‑hard 'back to basics' types, would like to go back to the days of DOS‑only programs, although there is a certain elegance in a well‑written DOS program, since without the bells and whistles we expect today it has the stripped‑down speed of a greyhound. It might look primitive, but it's still a lot faster than Windows 95 when carrying out simple tasks.
Until a few years ago, specialist applications were still manageable enough to be written by a single programmer, which minimised potential problems that can arise when different people have to get their code working together. For DOS applications, program code was often written in Assembly language (which is a low‑level language in which actions are carried out on individual bytes of memory). This resulted in faster performance, since everything could be carried out directly by the program at a much lower level, rather than ferrying data between the many program modules used by most of today's much larger applications. This is also the reason why so many games stayed as DOS‑only versions for so long, since it is far easier to 'take over' the hardware directly, giving faster performance, without having to abide by the additional protocol involved in Windows programming.
Nowadays, dozens of people have to be employed on every project, each individual or team working on a specific area, and this allows much more complex products to be written within a reasonable time‑span. Nobody has to re‑invent the wheel, since every application can use the core of standard components already available in Windows for carrying out basic operations. This team approach does involve a lot of planning, and very tightly specified code, so that each section neatly integrates into the whole. However, occasionally, critical core parts of code are still written 'by hand' using Assembly language, just like in the old days of DOS. This can provide a boost to performance, especially with pieces of code that are being carried out thousands of times a second (such as WAV file manipulation), since every tiny bit of time that can be 'shaved' off each operation can give appreciable improvements in overall performance, allowing more real‑time operations, or more simultaneous tracks. The excellent SAW hard disk recording package has always been renowned for its speed and number of available tracks, and this is because it used large chunks of Assembly language programming from the outset. As the Microsoft DirectX drivers have also shown, lower‑level programming brings more performance benefits.
In essence, DOS (or more properly MS‑DOS, since this operating system is what launched the Microsoft empire into an unsuspecting world) is what we all used to control our PCs before Windows came along. DOS was first introduced way back in 1981, when few personal computers possessed hard disks, and floppy disks were really floppy and of the 5.25‑inch variety. Each floppy disk provided the huge storage capacity of 360K (don't laugh, even in 1990, when I got my first PC, 1Mb was still considered more than enough RAM for anybody!). After the PC finished booting up into DOS, all you saw was the C: prompt, followed by a flashing cursor. To start any application you typed its filename, and then pressed the Return key. When you progressed to the dizzy heights of having your first hard drive (20Mb in my case), negotiating the hard disk was a matter of issuing a command to move to each different directory (or folder). If you wanted to move a file from one place to another, you had to type 'MOVE', followed by the source and destination filenames — no click‑and‑drag niceties!
For some years after Windows 3.0 and then 3.1 was released, die‑hard enthusiasts stayed with their chosen DOS operating system, because it was much faster than Windows (and still is, simply because of the extra overhead that provides the glossy point and click interface). Also, programmers writing for DOS were often still writing the whole package, rather than being able to rely on the host of ready‑built routines provided by Windows. Although this made their job much more involved, it removed some of the possibilities for 'bugs', simply because the DOS product was self‑contained, and did not have to work with a raft of other people's routines. Cakewalk (whose latest Pro Audio 6 incarnation was reviewed in the August SOS) started life as a DOS‑only program.
In all cases below, details of the syntax (the order in which the command and elements that follow it) can be easily found while in DOS. To obtain more information about any command, type in the command name, as shown below, followed by '/?' and text detailing all possible options will appear.
- CD (or CHDIR) changes the current directory, or displays the current directory name.
- CLS clears the screen, leaving the cursor at the top.
- COPY copies the files specified to the specified destination directory.
- DATE displays the system date and lets you amend it.
- DEL deletes the filenames you specify.
- DIR displays the contents of the current directory. However, unlike with Windows 95, there is no way to view 'hidden' files, which will not show up in a DOS session at all.
- DISKCOPY is useful for copying the contents of one floppy disk to another.
- EXIT returns to Windows, if this was running before the DOS session was started, or otherwise does nothing.
- MD makes a new directory with the filename you specify.
- MOVE is used in exactly the same way as COPY, but with an obvious difference!
- PATH shows the current paths that are searched automatically (see the 'Driving' section in the main text).
- RD removes (deletes) a specified directory.
- REM enables you to include comments (remarks) in a batch program, which either explain the function of another line within the file, or are added to temporarily prevent another command line from running.
- REN (or RENAME) renames the file or directory you specify.
- TIME displays the system time and lets you amend it.
- TYPE allows you to view the contents of a text file, and this can be extremely useful when browsing around in DOS.
- WIN starts the Windows operating system.