l102
MS-DOS User's Reference
Creating a batch file
Running a batch file
Suppose, for example, that
you
want
to
create
a
batch
file
to
format
and
check
a
new
disk.
To
do
this you simply follow
these
steps:
II]
First, type
the
following:
copy
con
checknew.bat
Press RETURN. This
command
tells MS·DOS
to
copy
the
informa-
tion
from
the
console
(keyboard)
to
the
file checknew.bat.
~
Next, type
the
following lines, pressing RETURN after each:
This
is
a
file
to
format
and
check
new
disks.
rem
rem
rem
pa.use
format
chkdsk
It
is
named
CHECKNEW.BAT.
Insert
new
disk
in
drive
B:
b:
Iv
b:
[AI
After
the
last line, press
CONTROL-Z
and
then
press
RETURN
to
save
the
batch file. MS-DOS displays
the
message
"1
File(s)
copied"
to
show
that
it
created
the
file_
[!]
Now,
to
execute
the
file, simply type
the
following command:
checknew
The
result is
the
same as
if
the
lines in
the
.bat
file
were
entered
from
the
keyboard
as
individual commands.
About Batch Processing
Here are a few things
you
should
know
before
you
run
a
batch
process
with
MS-DOS:
• You
must
name
each
batch file with an
extension
of
.bat.
•
To
execute
a batch file, you type only its filename and
not
the
extension.
•
If
you
press
CONTROL-C
while
the
batch file is running, MS-DOS
asks
you
to
confirm that you
want
to
terminate
the
batch
process.
•
If
you
remove
the
disk that contains a
batch
file being run,
MS-
DOS
prompts
you
to
reinsert
the
disk so
that
it
can
continue
processing
the
file.
• You
can
specify the name
of
another
batch
file as
the
last com-
mand
in
a batch file. This feature allows
you
to
call
one
batch
file from
another
when
the
first has finished.
[
[
[
[
[