Chapter 1: Batch files are just DR DOS commands. Some of your most useful batch files can be created by simply writing down the DR DOS commands you use to perform a particular task and then storing that command or those commands in a batch file. This chapter explains that concept in more detail.
Chapter 2: Creating your own batch files. DR DOS users have three general ways to write batch files: the COPY command, the editor included with DR DOS or some other editor. This chapter explains the advantages and disadvantages of each of these approaches.
Chapter 3: Batch file construction. This chapter explains naming conventions and layout considerations you need to understand when you begin to write batch files.
When you finish these three chapters, you will be able to consolidate one or more DR DOS commands you would normally enter from the command line prompt into a batch file.
Chapter 4: REM Documentation: "Why in the world did I do that?" The batch language only has a few commands of its own but it can also run any program you own. As a result, some batch files tend to become very long. Using the REM command to document those longer batch files can make following their logic easier when you have to modify them in the future. This chapter explains how to do that.
Chapter 5: Let's keep it quiet. The default mode of operation for a batch file is to have command echoing on, which means that commands are displayed on the screen before they are executed. By turning command echoing off, your screens will look much neater. This chapter explains how to do that.
Chapter 6: Talking to the user. Batch files frequently need to "talk" to the user to display information, ask questions or provide warnings. The ECHO command provides the method for doing this. This chapter explains how to use the ECHO command effectively.
Chapter 7: Using high-ordered ASCII characters. Your batch files can be made much more attractive by using some of the high- ordered ASCII characters available through DR DOS. This chapter explains how to use these characters.
Chapter 8: Hold that batch file! Sometimes you need for the batch file to wait for the user to catch up. Maybe it has put a lot of information on the screen for the user to read or the user needs a chance to press Ctrl-Break and halt the batch file. This chapter explains how to use the PAUSE command in a batch file to suspend its operation until a key is pressed.
Chapter 9: Applications and problems. Before moving on to the intermediate batch subcommands, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.
Chapter 10: Replaceable parameters. Unless you have a way to get information into a batch file, it is difficult to have the batch file perform differently each time it runs. Replaceable parameters are a method of adding additional information on the command line that the batch file then has access to. This information can be used as file names, extensions, subdirectories, commands, or just about anything you use in a batch file.
Chapter 11: Using more than ten replaceable parameters. When it first starts, the batch file only has access to its name and the first nine pieces of information you entered on the command line. This chapter show you how to gain access to additional information.
Chapter 12: Looping and program flow. This chapter shows you how to define different execution paths through the batch file and how to create loops within a batch file.
Chapter 13: The environment. The environment is an important scratch pad for the operating system. It uses the environment to store information that all the programs need access to.
Chapter 14: Errorlevel. The errorlevel is a one-byte portion of memory that programs can use to communicate to each other or with a batch file. While only a few DR DOS programs use the errorlevel, most batch file utilities use it to pass results back to the batch file that ran them. This chapter provides an overview of the Errorlevel.
Chapter 15: DR DOS punctuation. Many of the batch files you have seen so far have used varying types of DR DOS punctuation to help them perform their work. This chapter documents that punctuation as a resource to help you understand these batch files as well as write more powerful batch files of your own.
Chapter 16: Logic testing. The different paths you learned to create in Chapter 12 are useless unless you have a method of selecting different paths at different times. Additionally, the loops you learned to create in Chapter 12 are useless unless you have a way to get out of them. In both cases, logic testing is the solution. This chapter shows you how to build logic testing into your batch files. Logic testing is what turns a batch file away from being just a dumb script the computer plays back into an intelligent program.
Chapter 17: Applications and problems. Before moving on to the advanced batch subcommands, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.
Chapter 18: Advanced logic testing. In Chapter 13, we covered simple logic testing. This chapter expands logic testing to include all the available logic testing commands DR DOS offers and some more that are supplied by a utility program.
Chapter 19: Advanced getting information from users. DR DOS makes it fairly difficult to get information from the user, giving you just replaceable parameters and Ctrl-Break to do the job. This chapter shows how to use a utility program that comes with this book to greatly expand the ability of a batch file to interact with the user.
Chapter 20: Advanced screen design 1. Most batch files use a series of ECHO commands to communicate with the user in a very boring fashion. This chapter covers two ways to improve your screens using ASCII files: typing them to the screen, and converting them to a program with a screen compiler.
Chapter 21: Advanced screen design 2. This chapter continues where Chapter 17 leaves off by showing you how to used advanced ANSI commands to construct colorful and highly formatted screens. It also briefly covers the many other uses for ANSI.
Chapter 22: Batch file subroutines. Subroutines are one of the most powerful approaches available to writing complex batch files. This chapter shows you how to use them.
Chapter 23: When batch files don't work. Even after reading a book as good as this one, you are going to occasionally have problems with the batch files you write. While nothing can eliminate the need for you to work through the logic of your batch file to resolve this problem, this chapter shows you some ways to expedite the process.
Chapter 24: Applications and problems. Before moving on to the advanced batch subcommands, you should understand the commands and concepts covered so far. This chapter is a quick test. Pass it, and you're ready to move on.
Chapter 25: Batcmd: New batch file commands. In order to write really powerful batch files, you need a batch file utility to provide a few commands that DR DOS does not offer. This book includes a very powerful batch utility called Batch Commands, or Batcmd for short. You have already seen some of its power from Chapter 19. This chapter documents the full power of Batcmd.
Chapter 26: Builder and Builder Lite. When you decide that batch files are not powerful enough for your needs, the next step up is a batch file compiler. One of the most powerful and easy-to-use batch file compilers available is Builder from hyperkinetix. If you want to try a less powerful version, hyperkinetix, TAB Books and myself have combined to bring you Builder Lite.
Chapter 27: Dual Boot Utility. If you have not decided for sure to convert to DR DOS or if you have to maintain batch files that will run under both MS and DR DOS, then you will appreciate this nice utility from Keith Ledbetter. It lets you keep DR DOS 6 and MS DOS 5 on one hard disk and boot from either one easily without using floppy disks! Not only that, it is easy to install.
Chapter 28: An automated batch file help system. One problem with having a lot of batch files is remembering which batch file does what. As it turns out, batch files can solve this problem and, in the process, give you a set of very powerful tools for locating the right batch file for your needs.
Chapter 29: Simple batch file menus. The most common think you do with your computer is run different programs. Often, this involves entering several different commands. Well, batch files can automate the process and make it simple for you to start your different applications.
Chapter 30: Anti-viral batch files. It's hard to imagine why anyone would want to write a program to harm someone else's data. Never-the-less, a few sick individuals have done just that. Your best defense is safe computing, and any number of other books will explain this in detail for you. Another form of defense is an anti-viral software program; a number of good ones are available. If you do not want to spend the money for an anti-viral software package, then at least protect yourself with the approaches outlined in this chapter. In addition to some DR DOS-based approaches, it outlines a batch file that will tell you if COMMAND.COM becomes infected. Because COMMAND.COM is the most commonly infected program, you should be able to determine whether or not it's OK.
Chapter 31: A document archival system. Never lose an important file again! That is a strong claim, but this chapter will show you how.
Chapter 32: Simulating Doskey using batch files. The one thing I missed most when I switch over to DR DOS 6 was the Doskey program from MS DOS 5. Doskey gives you command line recall, keyboard macros, and the ability to enter multiple commands on a single command line. As it turns out, all these features can be added to DR DOS using nothing more than batch files and this chapter shows how. It even turns out that there are significant advantages to using batch files over Doskey.
Chapter 33: Smaller batch file applications. This chapter presents a number of batch file applications that were too small to put in a separate chapter.
Chapter 34: Applications and problems. Think of this as a final exam. You get to try out everything you have learned in this book so far.
When you turn on your computer, after performing a few necessary tasks, DR DOS processes two user-created files, CONFIG.SYS and AUTOEXEC.BAT. To a great extent, these two files determine the configuration of your computing environment. The CONFIG.SYS file is processed first, before even COMMAND.COM is loaded. For that reason, we will cover it first. The AUTOEXEC.BAT file is processed last, just before turning control over to you so we'll cover it last.
With batch files, the differences between MS and DR DOS are fairly minor-especially if you avoid the DR DOS 6 SWITCH and GOSUB commands. There is a fairly high change that a batch file written for DR DOS will run under MS DOS and that one written for MS DOS will run under DR DOS. What minor differences that do crop up are due to differences in command syntax and operation. For example, the MS DOS FIND command is case-sensitive, although you must use FIND /u with DR DOS; and the MS DOS COPY command does not copy 0-length files, while the DR DOS COPY command does.
However, this comparability does not hold with the CONFIG.SYS file. Chances are very high that a CONFIG.SYS file written for MS DOS 5 will not run under DR DOS and one written for DR DOS will not run under MS DOS. Part of the reason for this difference is the use of different names for the commands to load items into high memory. DR DOS 6 uses the HIDEVICE to load device drivers into high memory, while MS DOS 5 uses the DEVICEHIGH command; and DR DOS 6 loads buffers into high memory using the HIBUFFERS command, while MS DOS 5 automatically loads them into high memory if MS DOS is loaded into high memory.
There are also significant differences between DR DOS 5 and 6. DR DOS 5 offers only a few specialized commands for the CONFIG.SYS file, while DR DOS 6 offers an entire batch-like programming language for the CONFIG.SYS files. For these reasons, I have broken the configuration section down into four chapters:
Chapter 35: CONFIG.SYS under MS DOS 3.3. This chapter covers the basics of configuration and introduces those commands that were available under MS DOS 3.3. As a general rule, these configuration commands will run under any version of MS or DR DOS. All readers will want to read this chapter-even if you never plan on using MS DOS-since the basic components of the CONFIG.SYS file- commands like FILES and BUFFERS-are covered here.
Chapter 36: CONFIG.SYS under DR DOS 5. DR DOS 5 introduced only a couple of advancements to the CONFIG.SYS file, but those few advancements were very powerful and extremely useful. DR DOS 6 users should also read this chapter because those advancements continue to be just as powerful and useful under DR DOS 6.
Chapter 37: CONFIG.SYS under DR DOS 6. DR DOS 6 expanded the CONFIG.SYS file to have its own programming language that is every bit as powerful as the batch language. This gives the CONFIG.SYS file power and usefulness unheard of in the MS DOS world. This chapter explains how to use those enhancements.
Chapter 38: AUTOEXEC.BAT and shutdown files. The AUTOEXEC.BAT file is designed to set up your computing environment. However, if you write it like any other batch file, you are ignoring some of that power. This chapter shows you how to write your AUTOEXEC.BAT file for maximum power. Also, while neither DR or MS DOS offers a shutdown batch file that automatically runs when you turn the computer off, it would be a good idea to have one. This file could do things like park the heads on your computer. This chapter also explores this issue.
Appendix A: Solutions to problems. This appendix presents a solution to each of the problems in the book. These are not the only solutions, and your solution might even be better than the one given!
Appendix B: Program documentation. This appendix provides brief documentation on the programs that are included on the disk that comes with this book.
Appendix C: Batch file documentation. This appendix provides brief documentation on the batch files that are included on the disk that comes with this book.
The information for this book was taken from the last draft I submitted to the publisher. Since the publisher performed minor editing, the version you purchase in the store will be slightly different.
Order One Of These Books
. Amazon.com is an on-line bookstore with a very large list of books, including all of mine that are still in print. This link will take you to Amazon.com using a special page they set up to showcase all my books. They are the easiest way I know of to order my books on-line. Of course, you can use this page to order any of the books they carry.
© 2002 by Ronny Richardson, All Rights Reserved