ŵ[Ƶ̳]Ƶ̳[Ƶ̳]VBSƵ̳
[ļƷ]Ƭ[ļƷ]ߵ
б

[ԭ] VBSУ׼ϵͳʱ

batman 2013-1-10 18:23 ༭

ΪԶжʱʽWIN7 XPͨWIN8ԣ
  1. 'VBSУ׼ϵͳʱ BY BatMan http://www.bathome.net
  2. Dim objXML, Url, Message
  3. Message = "ϲ㣬ʱdz׼ȷУԣ"
  4. Set objXML = CreateObject("MSXML2.XmlHttp")
  5. Url = "http://open.baidu.com/special/time/"
  6. objXML.open "GET", Url, False
  7. objXML.send()
  8. Do Until objXML.readyState = 4 : WScript.Sleep 200 : Loop
  9. Dim objStr, LocalDate
  10. objStr = objXML.responseText
  11. LocalDate = Now()
  12. Set objXML = Nothing
  13. Dim objREG, regNum
  14. Set objREG = New RegExp
  15. objREG.Global = True
  16. objREG.IgnoreCase = True
  17. objREG.Pattern = "window.baidu_time\((\d{13,})\)"
  18. regNum = Int(objREG.Execute(objStr)(0).Submatches(0)) /1000
  19. Dim OldDate, BJDate, Num, Num1
  20. OldDate = "1970-01-01 08:00:00"
  21. BJDate = DateAdd("s", regNum, OldDate)
  22. Num = DateDiff("s", LocalDate, BJDate)
  23. If Abs(Num) >=1 Then
  24.   Dim DM, DT, TM, objSHELL
  25.   DM = DateAdd("S", Num, Now())
  26.   DT = DateValue(DM)
  27.   TM = TimeValue(DM)
  28.   If InStr(Now, "") Then
  29.     Dim Arr, Arr1, h24
  30.     Arr = Split(TM, " ")
  31.     Arr1 = Split(Arr(1), ":")
  32.     h24 = Arr1(0)
  33.     If Arr(0) = "" Then
  34.       h24 = h24 + 12
  35.       Else
  36.       If h24 = 12 Then h24 = 0
  37.     End If
  38.     TM = h24 & ":" & Arr1(1) & ":" & Arr1(2)
  39.   End If
  40.   Set objSHELL = CreateObject("Wscript.Shell")
  41.   objSHELL.Run "cmd /cdate " & DT, False, True
  42.   objSHELL.Run "cmd /ctime " & TM, False, True
  43.   Num1 = Abs(DateDiff("s", Now(), BJDate))
  44.   Message = "У׼ǰ" & vbCrLf _
  45.     & "׼ʱΪ" & vbTab & BJDate & vbCrLf _
  46.     & "ϵͳʱΪ" & vbTab & LocalDate & vbCrLf _
  47.     & "׼ʱ" & vbTab & Abs(Num) & "" & vbCrLf & vbCrLf _
  48.     & "У׼" & vbCrLf _
  49.     & "ϵͳʱΪ" & vbTab & Now() & vbCrLf _
  50.     & "׼ʱ" & vbTab & Num1 & ""
  51.   Set objSHELL = Nothing
  52. End If
  53. WScript.Echo Message
ƴ
1

ղ
ͬߣ

ظ 2# czjt1234


    Ϊʱʽ⣬ĵ12Сʱơ
޸Ϊ24СʱƣӦôϵͳʱ䶼24Сʱưɡ
ͬߣ

TOP

ߺ߹٣ʹWMI
  1. 'VBSУ׼ϵͳʱ BY BatMan http://www.bathome.net
  2. Dim objXML, Url, Message
  3. Message = "ϲ㣬ʱdz׼ȷУԣ"
  4. Set objXML = CreateObject("MSXML2.XmlHttp")
  5. Url = "http://open.baidu.com/special/time/"
  6. objXML.open "GET", Url, False
  7. objXML.send()
  8. Do Until objXML.readyState = 4 : WScript.Sleep 200 : Loop
  9. Dim objStr, LocalDate
  10. objStr = objXML.responseText
  11. LocalDate = Now()
  12. Set objXML = Nothing
  13. Dim objREG, regNum
  14. Set objREG = New RegExp
  15. objREG.Global = True
  16. objREG.IgnoreCase = True
  17. objREG.Pattern = "window.baidu_time\((\d{13,})\)"
  18. regNum = Int(objREG.Execute(objStr)(0).Submatches(0)) /1000
  19. Dim OldDate, BJDate, Num, Num1
  20. OldDate = "1970-01-01 08:00:00"
  21. BJDate = DateAdd("s", regNum, OldDate)
  22. Num = DateDiff("s", LocalDate, BJDate)
  23. If Abs(Num) >=1 Then
  24.   Dim DM, y, M, D, H, MI, S, NewDateTime
  25.   DM = DateAdd("S", Num, Now())
  26.   y = Year(DM)
  27.   M = Right(0 & Month(DM), 2)
  28.   D = Right(0 & Day(DM), 2)
  29.   H = Right(0 & Hour(DM), 2)
  30.   MI = Right(0 & Minute(DM), 2)
  31.   S = Right(0 & Second(DM), 2)
  32.   'ʱתUTCʽ
  33.   NewDateTime = y & M & D & H & MI & S & ".000000+480"
  34.   Dim objWMI, objItems, objItem
  35.   Set objWMI = GetObject("winmgmts:{(systemtime)}!\\.\Root\Cimv2")
  36.   Set objItems = objWMI.ExecQuery("Select * From Win32_OperatingSystem")
  37.   For Each objItem In objItems
  38.     objItem.SetDateTime NewDateTime
  39.   Next
  40.   Set objWMI = Nothing
  41.   Num1 = Abs(DateDiff("s", Now(), BJDate))
  42.   Message = "У׼ǰ" & vbCrLf _
  43.     & "׼ʱΪ" & vbTab & BJDate & vbCrLf _
  44.     & "ϵͳʱΪ" & vbTab & LocalDate & vbCrLf _
  45.     & "׼ʱ" & vbTab & Abs(Num) & "" & vbCrLf & vbCrLf _
  46.     & "У׼" & vbCrLf _
  47.     & "ϵͳʱΪ" & vbTab & Now() & vbCrLf _
  48.     & "׼ʱ" & vbTab & Num1 & ""
  49.   Set objSHELL = Nothing
  50. End If
  51. WScript.Echo Message
ƴ
ͬߣ

TOP

б