[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[日期时间] 10元求大神 开机检测到时间是某个个时间段就goto

应用场景,无盘,开机调用批处理,检测到时间是设定的时间段内就goto,不是就退出

本帖最后由 flashercs 于 2019-11-21 18:01 编辑
  1. @echo off
  2. set "起始时间=08:25:39.80"
  3. set "终止时间=19:51:42.00"
  4. set "mytime=%起始时间%"
  5. call :getTod time_1
  6. set "mytime=%终止时间%"
  7. call :getTod time_2
  8. set "mytime=%time%"
  9. call :getTod time_3
  10. set /a "time_dist1=time_2-time_1"
  11. if %time_dist1% LSS 0 set /a "time_dist1+=8640000"
  12. set /a "time_dist2=time_3-time_1"
  13. if %time_dist2% LSS 0 set /a "time_dist2+=8640000"
  14. if %time_dist2% lss %time_dist1% (
  15.   goto label
  16. ) else (
  17.   exit /b
  18. )
  19. :label
  20. echo now is %time%
  21. pause
  22. exit /b
  23. :getTod -- get a Time of Day value in 1/100th seconds
  24. ::   -- %~1: out - time of day
  25. SETLOCAL
  26. set t=%mytime: =0%
  27. set /a t=((1%t:~0,2%*60+1%t:~3,2%)*60+1%t:~6,2%)*100+1%t:~9,2%-36610100
  28. ( ENDLOCAL & REM RETURN VALUES
  29.     IF "%~1" NEQ "" SET %~1=%t%
  30. )
  31. GOTO:EOF
复制代码
微信:flashercs
QQ:49908356

TOP

  1. @echo off
  2. set t=08:45-20:02
  3. for /f "tokens=1-4 delims=:." %%a in ("%time: =%") do (set h=00%%a&set m=00%%b)
  4. set now=%h:~-2%:%m:~-2%
  5. echo;%now%
  6. for /f "tokens=1* delims=-" %%a in ("%t%") do (set t1=%%a&set t2=%%b)
  7. if "%t1%" lss "%t2%" (
  8.     if "%now%" geq "%t1%" (
  9.         if "%now%" leq "%t2%" (goto run)
  10.     )
  11. )
  12. if "%t1%" gtr "%t2%" (
  13.     if "%now%" geq "00:00" (
  14.         if "%now%" leq "%t2%" (goto run)
  15.     )
  16.    if "%now%" geq "%t1%" (
  17.         if "%now%" leq "23:59" (goto run)
  18.     )
  19. )
  20. goto end
  21. :run
  22. echo;in
  23. :end
  24. >nul ping /n 3 0
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表