Copy Code code as follows:
' VBS calibration system time by BatMan
Dim objxml, URL, message
Message = "Congratulations, this machine time is very accurate without proofreading!" "
Set Objxml = CreateObject ("Msxml2.xmlhttp")
URL = "http://open.baidu.com/special/time/"
Objxml.open "Get", Url, False
Objxml.send ()
Do Until objxml.readystate = 4:wscript.sleep 200:loop
Dim Objstr, Localdate
Objstr = Objxml.responsetext
Localdate = Now ()
Set Objxml = Nothing
Dim Objreg, Regnum
Set Objreg = New RegExp
Objreg.global = True
Objreg.ignorecase = True
Objreg.pattern = "window.baidu_time\ ((\d{13,}) \)"
Regnum = Int (Objreg.execute (OBJSTR) (0). Submatches (0))/1000
Dim olddate, Bjdate, Num, NUM1
Olddate = "1970-01-01 08:00:00"
Bjdate = DATEADD ("s", Regnum, Olddate)
Num = DateDiff ("s", Localdate, Bjdate)
If Abs (Num) >=1 Then
Dim DM, DT, TM, Objshell
DM = DateAdd ("S", Num, Now ())
DT = DateValue (DM)
TM = TimeValue (DM)
If InStr (now, "midday") Then
Dim Arr, ARR1, H24
ARR = Split (TM, "")
ARR1 = Split (ARR (1), ":")
H24 = Arr1 (0)
If ARR (0) = "PM" Then
H24 = H24 + 12
Else
If H24 = Then h24 = 0
End If
TM = h24 & ":" & Arr1 (1) & ":" & ARR1 (2)
End If
Set Objshell = CreateObject ("Wscript.Shell")
Objshell.run "Cmd/cdate" & DT, False, True
Objshell.run "Cmd/ctime" & TM, False, True
NUM1 = Abs (DateDiff ("s", Now (), bjdate))
Message = "" Pre-Calibrated "" & vbCrLf _
& "Standard Beijing time is:" & VbTab & Bjdate & VbCrLf _
& "The Local System time is:" & VbTab & Localdate & VbCrLf _
& "With Standard Time difference:" & VbTab & Abs (Num) & "SEC" & VbCrLf & VbCrLf _
& "" After Calibration "" & vbCrLf _
& "The Local System time is:" & VbTab & Now () & VbCrLf _
& "With Standard Time difference:" & VbTab & Num1 & "Seconds"
Set Objshell = Nothing
End If
WScript.Echo Message