Q:

echo in cmd file produces incorrect results

My .cmd file contains:
set /A "@zz+=1"
set @zz
echo:"%%@zz%%"

Produces:
@zz=4
"%@zz%"

The set @zz shows the variable being properly populated, but echo acts as though it is not there.  Curiously, the commands work fine when run from the command prompt.

A:

Actually, batch is doing exactly what it's supposed to. While the normal escape character in batch is ^, you escape % in batch scripts like %%, so you're telling the script to print a literal %, then the string @zz, then another literal %.
If you really want to echo %4%, you need three % signs on each side: echo:"%%%@zz%%%"
This tells batch to print a literal %, then the value of %@zz%, and then another literal %.

