goto time
:time
set tm=%time%
set hh=%tm:~0,2%
set mm=%tm:~3,2%
set ss=%tm:~6,2%
set ms=%tm:~7,2%
goto date
:date
set dt=%date%
set wd=%dt:~0,3%
set mh=%dt:~4,2%
set dy=%dt:~6,2%
set yr=%dt:~8,4%
goto scheduletimes
:scheduletimes
goto hour1
:hour1
for /f "tokens=1*delims=0" %%a in ("$0%hh%") do set /a "HH"="%%b"
if %HH% equ 6 goto minutes1
pause
goto time
:minutes1
for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a "MM"="%%b"
if "%MM%"=="00" goto seconds1
pause
goto time
:seconds1
for /f "tokens=1*delims=0" %%a in ("$0%ss%") do set /a "SS"="%%b"
if %SS% lss 10 goto day1
pause
goto time
:day1
echo success
echo %hh%
echo %mm%
echo %ss%
pause
goto time
正如你们所看到的,这是一个时间检查循环。看看时间是不是6:10:>10。基本上我的问题是它运行良好,直到它到达那个时间时执行命令。在本节中,只要它变为 <10 秒:
:minutes1
for /f "tokens=1*delims=0" %%a in ("$0%mm%") do set /a "MM"="%%b"
if %MM% equ 0 goto seconds1
它停止将MM设置为%mm%并给我一个Missing Operand错误。
任何帮助将不胜感激,使其在第一次运行后继续工作。
(是的,我确实知道有暂停,没有@echo 关闭,这是出于调试目的。它在关闭@echo 并且没有暂停的情况下这样做)
编辑:日志
C:\Users\krato_000\Desktop>goto scheduletimes
C:\Users\krato_000\Desktop>goto hour1
C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$0 6") do set /a "
HH"="%b"
C:\Users\krato_000\Desktop>set /a "HH"=" 6"
C:\Users\krato_000\Desktop>if 6 EQU 6 goto minutes1
C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$000") do set /a "
MM"="%b"
C:\Users\krato_000\Desktop>set /a "MM"=""
Missing operand.
C:\Users\krato_000\Desktop>if "00" == "00" goto seconds1
C:\Users\krato_000\Desktop>for /F "tokens=1*delims=0" %a in ("$019") do set /a "
SS"="%b"
C:\Users\krato_000\Desktop>set /a "SS"="19"
C:\Users\krato_000\Desktop>if 19 LSS 10 goto day1
C:\Users\krato_000\Desktop>pause
Press any key to continue . . .