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
I built my answer thanks to previous contributors.
Not having time for a custom counter.exe, I downloaded sed for FREEDOS.
And then the batch code could be, emulating "wc -l" with the utility sed, something like this according to your loop (I just use it to increment through executions starting from "1" to n+1):
Just remember to manually create a file "test.txt" with written on the first row
0
sed -n '$=' test.txt > counter.txt
set /P Var=< counter.txt
echo 0 >> test.txt