How to increment variable under DOS?

前端 未结 9 1657
清酒与你
清酒与你 2021-02-06 21:36

I\'ve spent the past 3hrs trying to work this out but just couldn\'t find a solution. Here\'s my batch script:

if NOT Exist Counter.txt GOTO START
Type c:\\count         


        
9条回答
  •  天涯浪人
    2021-02-06 22:06

    I realize you've found another answer - but the fact is that your original code was nearly correct but for a syntax error.

    Your code contained the line

    set /A COUNTER=%COUNTER%+1
    

    and the syntax that would work is simply...

    set /A COUNTER=COUNTER+1
    

    See http://ss64.com/nt/set.html for all the details on the SET command. I just thought I'd add this clarification for anyone else who doesn't have the option of using FreeDOS.

提交回复
热议问题