Microsoft KB Archive/34760: Difference between revisions
m (Text replacement - "<" to "<") |
m (Text replacement - ">" to ">") |
||
Line 12: | Line 12: | ||
<div id="TitleRow"> | <div id="TitleRow"> | ||
= <span id="KB34760"></span>Missing <CR | = <span id="KB34760"></span>Missing <CR> after Batch Label Causes Repeat of Last Command = | ||
Line 59: | Line 59: | ||
The following batch file | The following batch file | ||
<pre class="fixed_text">echo hello <cr | <pre class="fixed_text">echo hello <cr> | ||
:label <cr | :label <cr> | ||
<eof | <eof> | ||
</pre> | </pre> | ||
will produce the following output: | will produce the following output: | ||
<pre class="fixed_text">C | <pre class="fixed_text">C>echo hello | ||
hello | hello | ||
C | C> | ||
C | C> | ||
</pre> | </pre> | ||
If the carriage return after the label is omitted, as follows | If the carriage return after the label is omitted, as follows | ||
<pre class="fixed_text">echo hello <cr | <pre class="fixed_text">echo hello <cr> | ||
:label <eof | :label <eof> | ||
</pre> | </pre> | ||
the file will produce the following output: | the file will produce the following output: | ||
<pre class="fixed_text">C | <pre class="fixed_text">C>echo hello | ||
hello | hello | ||
hello | hello | ||
C | C> | ||
C | C> | ||
</pre> | </pre> | ||
Latest revision as of 10:19, 21 July 2020
Article ID: 34760
Article Last Modified on 11/25/2003
APPLIES TO
- Microsoft MS-DOS 3.3 Standard Edition
- Microsoft MS-DOS 3.3a
- Microsoft MS-DOS 4.0 Standard Edition
- Microsoft MS-DOS 5.0 Standard Edition
This article was previously published under Q34760
SUMMARY
If the last line in a batch file is a label and there is no carriage return character after the label, the command immediately preceding the label will be executed twice.
The workaround for this problem is to include a carriage return at the end of a label.
Microsoft has confirmed this to be a problem in MS-DOS versions 3.3, 3.30a, 4.0, and 5.0. This problem was corrected in MS-DOS version 6.0.
MORE INFORMATION
The following batch file
echo hello <cr> :label <cr> <eof>
will produce the following output:
C>echo hello hello C> C>
If the carriage return after the label is omitted, as follows
echo hello <cr> :label <eof>
the file will produce the following output:
C>echo hello hello hello C> C>
Additional query words: 3.30 3.30a 4.00 5.00 noupd
Keywords: KB34760