1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| @echo off setlocal call:setESC
call:doFailed "-------- [xxx] failed !!!"
call:doSuccess "-------- [fff] success --------"
set START=%time% set num=0
set /a num+=5 timeout 1
call:doTotal %num% "%START%"
goto:eof
::---------------------- functions ----------------------------- :doSuccess echo. echo %ESC%[32m%~1%ESC%[0m echo. goto:eof
:doFailed echo. echo %ESC%[91m%~1%ESC%[0m echo. goto:eof
:doTotal set a=%~2 set /a h=%a:~0,2% set /a m=%a:~3,2% set /a s=%a:~6,2% set /a start = %h%*60*60+%m%*60+%s% echo start : %start%
set a=%time% set /a h=%a:~0,2% set /a m=%a:~3,2% set /a s=%a:~6,2% set /a end = %h%*60*60+%m%*60+%s% echo end : %end%
set /a use = %end%-%start%
echo. echo -------- %ESC%[32m[ total : %~1 ]%ESC%[0m -------- echo -------- %ESC%[32m[ time : %use% ]%ESC%[0m -------- echo. goto:eof
:setESC for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set ESC=%%b goto:eof ) goto:eof ::---------------------- functions end-----------------------------
|