我正在使用Windows 8並且想要寫入bat文件來記錄運行任務的時間。所以,我寫這篇文章:Windows命令提示計算錯誤
@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%
能你幫我?我在尋找有關的問題,但我找不到什麼可mached巫婆我的問題
感謝您的幫助
這是在你輸入'set /?' –