First, please excuse me if there is another, better, way to do this and I don't know what that is, but I often have the situation where I want to time something but I want to substantially reformat in some way the result(s) of executing the "Timer" command(s), i.e. putting the result(s) of the "Timer" command(s) into variables.
Well the first and most obvious solution is to do this:
Well this really doesn't work at all. The results of doing the above are:
There is obviously no elapsed time at all (although you could figure it out) and I would assume that this is because the timer wasn't "on" when it was turned "off". (I assume that this is because the "Timer" command(s) are being executed in "sub shell(s)").
Well here is a quite easy way that actually works:
Which produces:
What you would hope for/expect.
Well the first and most obvious solution is to do this:
Code:
Set StartTime=%@ExecStr[Timer On /1]
Delay 10
Set EndTime=%@ExecStr[Timer Off /1]
@Echo Start Time: %StartTime
@Echo End Time: %EndTime
Code:
Start Time: Timer 1 on: 15:37:30
End Time: Timer 1 off: 15:37:40
Well here is a quite easy way that actually works:
Code:
Do Result In /P (Timer On /1) (
Set StartTime=%@Right[-12,%Result]
)
Delay 10
Do Result In /P (Timer Off /1) (
Set EndTime=%@Right[-13,%Result]
)
@Echo Start Time: %StartTime
@Echo End Time: %EndTime
Code:
Start Time: 15:37:40
End Time: 15:37:50 Elapsed: 0:00:10.21