Home / Windows 7 / Getting Started

CMD and BAT Files

One of the easiest ways to automate command line tasks is to use batch files. A batch file works just as if you'd typed the commands manually, but you're asking the computer to type them.

Users have relied on batch files of various sorts for many years because they're quick to create, easy to understand, and painless to modify. Testing a batch file is simple-you don't need any fancy tools or a debugger. In fact, as far as any kind of programming goes, working with batch files represents the least difficult way to get started. You literally enter the commands in the same order as you do at the command prompt. With a little effort in Windows, you can cut and paste your way to a completed batch file.

One of the most interesting uses of batch files are the AutoExec.NT and Config.NT files used to configure the command line. These two files represent a significant opportunity to configure the command environment to meet specific needs without doing much more than selecting a menu option, yet most people miss this opportunity. This tutorial demonstrates that a little code mixed with some simple instructions really can do a lot to make the command line environment a pleasure to work with.

Although you won't spend a lot of time debugging your batch files, they can become complex enough that you'll need to do some debugging. The last section of this tutorial provides you with some techniques for debugging your batch file as necessary. This last section completes the batch file picture for you and provides you with a complete set of batch file tools.

In this tutorial, you'll learn how to do the following:

  • Create a new command interpreter and configure it
  • Perform basic command line tasks
  • Create batch files
  • Test batch files