Rem 检测时间
Rem jiaoben
Dim SvrName(14),xPost,HttpAdd,NowTime,StartTime
StartTime=Now
SvrName(1) = "time-nw.nist.gov"
SvrName(2) = "time-a.nist.gov"
SvrName(3) = "time-b.nist.gov"
SvrName(4) = "time-a.timefreq.bldrdoc.gov"
SvrName(5) = "time-b.timefreq.bldrdoc.gov"
SvrName(6) = "time-c.timefreq.bldrdoc.gov"
SvrName(7) = "utcnist.colorado.edu"
SvrName(8) = "time.nist.gov"
SvrName(9) = "nist1.datum.com"
SvrName(10) = "nist1.dc.glassey.com"
SvrName(11) = "nist1.ny.glassey.com"
SvrName(12) = "nist1.sj.glassey.com"
SvrName(13) = "nist1.aol-ca.truetime.com"
SvrName(14) = "nist1.aol-va.truetime.com" 【14个获取网络时间的地址,这么多地址总不会都连接不上吧】
Set xPost=createObject("Microsoft.XMLHTTP")
Set Obj=createObject("Wscript.shell")
While NowTime=""
i=1
For 14
HttpAdd="Http://"&SvrName(i)&":13":NowTime=""
xPost.Open "
ut",HttpAdd,False
xPost.Send()
Delay 10
If xPost.readyState=4
NowTime=mid(xPost.responsetext,8,17)
If NowTime<>""
NowTime=CDate(NowTime)+ 8 / 24 【这里是转换时间格式】
Goto EndConnect
Else
xPost.abort()
NowTime="" 【获取到的网络日期时间】
EndIf
EndIf
i=i+1
EndFor
If DateDiff("s",StartTime,Now)>=30 And NowTime=""
Obj.popup "请确定你已经连接上了互联网!",0,"网络时间"
Goto EndConnect
EndIf
EndWhile
新手可以在这里弹窗看下获取到的网路时间
MessageBox NowTime 【此句可删除】