本帖最后由 pcl_test 于 2017-3-20 14:24 编辑
[已解决]网络时间同步vbs代码,以前可用。现在出现错误提示。求解决。谢谢
错误提示如下。
getTime.vbs(6,1)vbscript运行时错误:类型不匹配:‘s’- @echo off&setlocal enabledelayedexpansion
-
- ping 127.0.0.1 -n 2 >nul 2>nul
-
- title 获取网络时间,同步到本机(需联网)
- cd /d "%tmp%"
- (
- echo With CreateObject("Microsoft.XMLHTTP"^)
- echo .open "GET", "http://time.tianqi.com/", False
- echo .send
- echo s = Split(Split(.responseText, "new Date(("^)(1^), "+"^)(0^)
- echo End With
- echo WSH.Echo DateAdd("s", s * 1, "1970-1-1 8:00"^)
- )>getTime.vbs
-
-
- ——————————————————————————
- cls
- for /l %%m in (1,1,180) do (
-
- ping 127.0.0.1 -n 2 >nul 2>nul
-
- ping time.tianqi.com -n 1 >nul 2>nul
-
- echo !errorlevel!
- if !errorlevel! equ 0 goto :neta
-
- echo 外网不通
- )
-
- echo 外网不通,持续30分钟
-
- exit
-
-
- :neta
- echo 外网通,同步本机时间
- pause
- for /f "tokens=1*" %%i in ('cscript //nologo gettime.vbs') do date %%i & time %%j
- echo 本机系统时间设置完成!
-
- pause
-
-
- exit
复制代码 getTime.vbs代码如下:- With CreateObject("Microsoft.XMLHTTP")
- .open "GET", "http://time.tianqi.com/", False
- .send
- s = Split(Split(.responseText, "new Date((")(1), "+")(0)
- End With
- WSH.Echo DateAdd("s", s * 1, "1970-1-1 8:00")
复制代码
|