我正在使用 Windows 8 并想编写 bat 文件来记录任务运行的时间。所以我写这个:
@echo off
setlocal
SET STARTTIME=%TIME%
.....do sth. smart.....
SET ENDTIME=%TIME%
SET /A DURATION=%ENDTIME%-%STARTTIME%
SET /A DURATIONH=%DURATION%/360000
SET /A DURATIONM=(%DURATION%-%DURATIONH%*360000)/6000
SET /A DURATIONS=(%DURATION%-%DURATIONH%*360000-%DURATIONM%*6000)/100
SET /A DURATIONHS=(%DURATION%-%DURATIONH%*360000-%DURATIONM%*6000-%DURATIONS%*100)
if %DURATIONH% LSS 10 SET DURATIONH=0%DURATIONH%
if %DURATIONM% LSS 10 SET DURATIONM=0%DURATIONM%
if %DURATIONS% LSS 10 SET DURATIONS=0%DURATIONS%
if %DURATIONHS% LSS 10 SET DURATIONHS=0%DURATIONHS%
echo ------------------------------------------------------------------------------------------
echo task start time : %STARTTIME%
echo task end time : %ENDTIME%
echo task end in time : %DURATIONH%:%DURATIONM%:%DURATIONS%,%DURATIONHS%
echo ------------------------------------------------------------------------------------------
endlocal
C:
PAUSE
我运行它并通过但日志时间是(fe):
task start time 14:35:36,24
task end time 14:39:43,55
task end in time : 00:00:00,14
并在此显示错误缺少运算符:
SET /A DURATION=%ENDTIME%-%STARTTIME%
你可以帮帮我吗?我正在搜索那个问题,但我找不到任何东西可以解决我的问题
感谢帮助