One day, I'm bored, I opened up cmd and typed in this piece of code:
@echo off & color 0a & set /a count=0 & main & set /a count+=1 & echo %count% & goto main
And surprisingly, the program executed for only a second. 0_o
I then wrote the code in the normal batch script format, which is like:
@echo off color 0a set /a count=0 :main set /a count+=1 echo %count% goto :main Obviously no errors, program runs perfectly.
So what's going on with the 1st piece of code? The command is the same (different format though) but why is it executed for only a sec?
Thanks in advance!
&&instead of&.&is fine and correct. This is a delayed expansion problem (and of course,gotodoesn't work on commandline - even if the label was correct (:main))