How to increment variable under DOS?

前端 未结 9 1645
清酒与你
清酒与你 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:17

    I've found my own solution.

    Download FreeDOS from here: http://chtaube.eu/computers/freedos/bootable-usb/

    Then using my Counter.exe file (which basically generates a Counter.txt file and increments the number inside every time it's being called), I can assign the value of the number to a variable using:

    Set /P Variable =< Counter.txt
    

    Then, I can check if it has run 250 cycles by doing:

    if %variable%==250 echo PASS
    

    BTW, I still can't use Set /A since FreeDOS doesn't support this command, but at least it supports the Set /P command.

提交回复
热议问题