Article ID: 34760 - View products that this article applies to.
This article was previously published under Q34760
This article has been archived. It is offered "as is" and will no longer be updated.
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.
The following batch file
will produce the following output:
echo hello <cr> :label <cr> <eof>
If the carriage return after the label is omitted, as follows
C>echo hello hello C> C>
the file will produce the following output:
echo hello <cr> :label <eof>
C>echo hello hello hello C> C>
Article ID: 34760 - Last Review: August 23, 2013 - Revision: 3.0
Contact us for more help
Connect with Answer Desk for expert help.