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
In this tutorial:
- Starting the Command Interpreter
- Using the CMD Switches
- Working with the Command Interpreter in the Registry
- Modifying Config.NT
- Displaying the Config.NT Commands
- Modifying AutoExec.NT
- Saving Memory Using the LH Command
- Defining Application Compatibility with the SetVer Utility
- Using Common DOS Utilities
- Formatting a Disk with the Format Utility
- Terminating a Session Using the Logoff Utility
- Managing Environment Variables with the Set Command
- Managing Environment Variables with the SetX Utility
- Using Debugging Utilities
- Working at the Command Prompt
- Managing Usernames and Passwords with CmdKey
- Changing Screen Colors with the Color Command
- Obtaining Command Line Help with the Help Utility
- Creating Batch Files
- Using the Choice Command
- Using the For Command
- Using the Goto Command
- Using the Prompt Command
- Using the WaitFor Utility