- May
- 13,272
- 187
NO, No, No. The entire rest of your batch file is in the DO loop. But you didn't end it with ENDDO so it falls right out of the batch file.
There are two forms of DO.
1. DO ... (command)
2. DO ...
command
command
...
ENDDO
Yours is of the second kind and the batch file ends before any corresponding ENDDO is found. Don't believe me ... put an ENDDO where you think the DO is over and you won't see StartTime and EndTime (and there would be an error message if you weren't in a DO loop).
There are two forms of DO.
1. DO ... (command)
2. DO ...
command
command
...
ENDDO
Yours is of the second kind and the batch file ends before any corresponding ENDDO is found. Don't believe me ... put an ENDDO where you think the DO is over and you won't see StartTime and EndTime (and there would be an error message if you weren't in a DO loop).
Code:
@Echo Off
::SetLocal
Do StartTime In /P Timer on /2()
EndDo
Set I=
Do While %I LT 10000
Set /A I+=1
EndDo
Do EndTime In /P Timer off /2()
EndDo
@Echo Start Time: %@Word[3,%StartTime]
@Echo End Time: %@Word[3,%EndTime] Elapsed Time: %@Word[5,%EndTime]
::EndLocal
Quit 0
v:\> dotest.btm
Start Time:
End Time: Elapsed Time: