You??™ll want to put more frequently used, general-purpose batch files in a
folder specified in the system path (see the upcoming sidebar, ???The Path Less
Travelled???), so that they can be executed regardless of the current working
directory.
Although batch files can run Windows programs (just type notepad to
launch Notepad), it??™s preferable to run Windows programs with WSH
scripts, because they??™ll be able to run without having to first load a Command
Prompt window.
In addition to the standard DOS commands, most of which are documented
earlier, batch files use a couple of extra statements to fill the holes.
Variables, conditional statements, and for...next loops are all implemented
with statements that are ordinarily not much use outside of batch
files.
The next few section cover the concepts used to turn a task or a string of
DOS commands into a capable batch file.
Variables and the Environment
The use of variables in batch files can be somewhat confusing. All variables
used in a batch file (with the exception of command-line parameters) are
stored in the environment??”an area of memory that is created when you first
boot and kept around until the computer is turned off. The environment
variable space is discussed in more detail in the upcoming sidebar, ???The
Path Less Travelled.???
To view the contents of the environment, type set without any arguments.
To set a variable to a particular value, type this command:
set VariableName=Some Data
558 | Chapter 9: Scripting and Automation
The Path Less Travelled
Although it isn??™t really emphasized as much as it was in the heyday of
DOS and Windows 3.
Pages:
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777