Batch Files: The Other Way to Do It
When it comes to quick-and-dirty scripting, it's hard to beat DOS batch files. Batch files, similar to WSH scripts (discussed in Chapter 9), are plain-text files with the .bat filename extension. However, rather than relying on a complex, unfamiliar scripting language, batch files simply consist of one or more DOS commands, typed one after another.
One of the problems with Windows-based scripting (see Chapter 9) is that it tries to control a graphical environment with a command-based language. Because DOS is a command-based interface, DOS-based scripting (batch files) is a natural extension of the environment.
Consider the following four DOS commands:
c: cd \windows\temp attrib -r *.tmp del *.tmp
If you type these commands into a plain-text editor, such as Notepad, save it into a .bat file, and then execute the batch file by double-clicking or typing its name at the Command Prompt, it will have the same effect as if the commands were manually typed consecutively at the prompt. Obviously, this can be a tremendous time saver if you find yourself entering the same DOS commands repeatedly.
When you run a batch file, each command in the file will be
displayed (echoed) on the screen before it's executed, which can be
unsightly for the more compulsive among us. To turn off the echoing of
any given command, precede it with the @
character. To turn off the printing of all commands in a
batch file, place the command @echo
off
at the beginning of the batch ...
Get Windows XP Annoyances for Geeks, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.