标题: [日期时间] 10元求大神 开机检测到时间是某个个时间段就goto [打印本页]
作者: yapda 时间: 2019-11-21 16:15 标题: 10元求大神 开机检测到时间是某个个时间段就goto
应用场景,无盘,开机调用批处理,检测到时间是设定的时间段内就goto,不是就退出
作者: flashercs 时间: 2019-11-21 16:45
本帖最后由 flashercs 于 2019-11-21 18:01 编辑
- @echo off
- set "起始时间=08:25:39.80"
- set "终止时间=19:51:42.00"
-
- set "mytime=%起始时间%"
- call :getTod time_1
- set "mytime=%终止时间%"
- call :getTod time_2
- set "mytime=%time%"
- call :getTod time_3
- set /a "time_dist1=time_2-time_1"
- if %time_dist1% LSS 0 set /a "time_dist1+=8640000"
- set /a "time_dist2=time_3-time_1"
- if %time_dist2% LSS 0 set /a "time_dist2+=8640000"
-
- if %time_dist2% lss %time_dist1% (
- goto label
- ) else (
- exit /b
- )
-
- :label
- echo now is %time%
- pause
- exit /b
-
- :getTod -- get a Time of Day value in 1/100th seconds
- :: -- %~1: out - time of day
- SETLOCAL
- set t=%mytime: =0%
- set /a t=((1%t:~0,2%*60+1%t:~3,2%)*60+1%t:~6,2%)*100+1%t:~9,2%-36610100
- ( ENDLOCAL & REM RETURN VALUES
- IF "%~1" NEQ "" SET %~1=%t%
- )
- GOTO:EOF
复制代码
作者: zaqmlp 时间: 2019-11-21 17:09
- @echo off
- set t=08:45-20:02
-
- for /f "tokens=1-4 delims=:." %%a in ("%time: =%") do (set h=00%%a&set m=00%%b)
- set now=%h:~-2%:%m:~-2%
- echo;%now%
- for /f "tokens=1* delims=-" %%a in ("%t%") do (set t1=%%a&set t2=%%b)
- if "%t1%" lss "%t2%" (
- if "%now%" geq "%t1%" (
- if "%now%" leq "%t2%" (goto run)
- )
- )
- if "%t1%" gtr "%t2%" (
- if "%now%" geq "00:00" (
- if "%now%" leq "%t2%" (goto run)
- )
- if "%now%" geq "%t1%" (
- if "%now%" leq "23:59" (goto run)
- )
- )
- goto end
- :run
- echo;in
- :end
- >nul ping /n 3 0
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |