document updated 13 years ago, on Mar 24, 2011
Command reference:
Syntax reference / examples:
Command-line parsing
: begining of a comment (as long as it's followed by a space)
: this is a test
rem this is another test
^ line continuation
echo hello ^
world
or general escape really
echo ^> ^^ ^<
%var% variable reference
set foo=bar
echo %foo%
& command separator (for putting multiple statements on one line)
echo head & echo heels
&& only execute the next statement if the last one succeeded
del doesntexist.txt && echo succeeded
|| only execute the next statement if the last one failed
del doesntexist.txt || echo failed
.. > log 2>&1 Redirect stderr as well as stdout
.. 2>&1| less
These are simplified rules. In reality, some of these are hacks (eg. using colon for a comment) and may not act as expected in all cases. When in doubt, search alt.msdos.batch.nt.
Further Resources
alt.msdos.batch.nt newsgroup
many good links
MS-DOS 1.25 to 8.0 boot disks (use rawwrite)
Tips
- Single-step used to be available via "command.com /y /c script.bat". However, it's no longer available, so just comment-out "@echo off" instead