@echo off
set recordfilename="lastruntime.txt"
set firstrun=False
if not exist %recordfilename% set firstrun=True
REM Get current time
REM assumes 24 hr time between
REM 0:00:00.00 and 23:59:59.99
set nowtime=%time%
REM get 2 character hour string
set nhh=%nowtime:~0,2%
REM Remove leading space when using
REM using 24 hour time format (hour < 10)
if "%nhh:~0,1%"==" " set nhh=%nhh:~1,1%
REM If hour is "0" remove altogether
if "%nhh:~0,1%"=="0" set nhh=
REM get 2 digit minute string
set nmm=%nowtime:~3,2%
REM get 2 digit seconds string
set nss=%nowtime:~6,2%
REM get 2 digit seconds/100 string
set ncs=%nowtime:~9,2%
REM Create time string
set TimeString=%nhh%%nmm%%nss%%ncs%
REM Remove leading zero if hour was 0 and minute < 10
if "%TimeString:~0,1%"=="0" set TimeString=%TimeString:~1,255%
REM If not first run, get last run time from file
if "%firstrun%"=="False" set /p lastruntime=<%recordfilename%
REM Write this time record to file
echo %TimeString% > %recordfilename%
REM If this is first run, quit
if "%firstrun%"=="True" goto end
REM Subtract this time from last time
set /a diff=%TimeString%-%lastruntime%
if %diff% lss 0 goto Less
if %diff% equ 0 goto Equal
if %diff% gtr 0 goto More
:Less
Echo This time earlier than previous
goto end
:Equal
Echo This time same as previous
goto end
:More
Echo This time later than previous
:end