本帖最后由 zaqmlp 于 2022-8-10 15:53 编辑
bat需存为ANSI/GB2312/GBK编码- @echo off&cd /d "%~dp0"
- rem 截取第3行第2个字符之后内容
- set line=3
- set index=2
- set "url=http://www.xxx.com/yyy.txt"
- (echo;var http=new ActiveXObject^('Msxml2.XMLHTTP'^);
- echo;http.open^('GET', "%url%", false^);
- echo;http.send^(^);
- echo;WSH.echo^(http.ResponseText^);
- )>"%tmp%\j.j"
- for /f "tokens=1* delims=:" %%a in ('cscript -nologo -e:jscript "%tmp%\j.j"^|findstr /n .*') do (
- if %%a equ %line% set serverdate=%%b
- )
- call set "serverdate=%%serverdate:~%index%%%"
- >"%tmp%\v.v" echo;WSH.echo Year(date) ^& right("0" ^& Month(date),2) ^& right("0" ^& Day(date),2)
- for /f %%a in ('cscript -nologo -e:vbscript "%tmp%\v.v"') do set localdate=%%a
- echo;服务器日期:"%serverdate%"
- echo;本机日期:"%localdate%"
- if "%serverdate%" leq "%localdate%" (echo;时间过期&goto :end)
- echo;大于时运行的代码
- :end
- pause
- exit
复制代码
|