ŵ[Ƶ̳]Ƶ̳[Ƶ̳]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

ղ
ͬߣ

29У±Խ

QQ 20147578

TOP

ظ 2# czjt1234


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

TOP

522235677 2013-1-10 14:13 ༭

ԺͷˣеУ׼ɱᱨ

TOP

ڳлȡϢʱʾ12

TOP

һϵͳĬ϶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

UNC ѡ

JS
  1. <title>
  2.     EasyX v20120603(beta) װ
  3. </title>
  4. <script type="text/javascript">
  5.     function GetSystemVersion() {
  6.         var os = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem");
  7.         for (var e = new Enumerator(os); ! e.atEnd(); e.moveNext()) {
  8.             var v = e.item().Version;
  9.             var ss = v.split('.');
  10.             return ss[0] + ss[1];
  11.         }
  12.         return - 1;
  13.     }
  14.     if (GetSystemVersion() >= 60) {
  15.         var cmd = location.pathname;
  16.         if (cmd.substring(cmd.length - 4) != ".HTA") {
  17.             var Shell = new ActiveXObject("Shell.Application");
  18.             Shell.ShellExecute("mshta.exe", "\"" + cmd.substring(0, cmd.length - 4) + ".HTA\"", "", "runas", 1);
  19.             window.close();
  20.             exit(0);
  21.         }
  22.     }
  23. </script>
ƴ
ǧˮǧ¡ǧˮӳǧƣ졣    http://yu2n.qiniudn.com/

TOP

Ҳд

Function Set_Net_DateTime()
  Dim attrib,day,month,year,hours
  'On Error Resume Next
  attrib=Split(getHTTPPage("http://stdtime.gov.hk:13"))'30 JAN 2012 00:04:42 HKT
  day=attrib(0)
  month=int(instr("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",attrib(1))/3)+1
  year=attrib(2)
  hours=attrib(3)
  Set objSWbemDateTime=CreateObject("WbemScripting.SWbemDateTime")
  objSWbemDateTime.SetVarDate year&"-"&month&"-"&day&" "&attrib(3),True '"2009-3-30 22:38:00"
  Set objWMIService=GetObject("winmgmts:{(Systemtime)}\\.\root\cimv2")
  Set colOSes=objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
  For Each objOS In colOSes
    objOS.SetDateTime objSWbemDateTime.Value
  Next
  Set objSWbemDateTime=nothing
  set objWMIService=nothing
  set colOSes=nothing
End Function

TOP

yu2n 2019-5-26 12:41 ༭

2019.05.26  ѸʱԴվΪʱԴ (Զ HTTP ޸Ĵе http://www.microsoft.com )

Win7x64 / Win10x64 ͨ
  1. 'VBSУ׼ϵͳʱ BY Yu2n  2019.05.26
  2. Option Explicit
  3. RunAsAdminX64
  4. Main
  5. '************************************************************************
  6. Sub Main()
  7. '************************************************************************
  8. Dim dtNet, dtLocal1, dtLocal2, lngOffset1, lngOffset2, strMessage
  9. dtNet = GetNetTime("http://www.microsoft.com")
  10. dtLocal1 = Now()
  11. lngOffset1 = Abs(DateDiff("s", dtNet, dtLocal1))
  12. If lngOffset1 > 1 Then
  13. SetDateTime dtNet
  14. dtLocal2 = Now()
  15. lngOffset2 = Abs(DateDiff("s", dtNet, dtLocal2))
  16. strMessage = "У׼ǰ" & vbCrLf _
  17. & "׼ʱΪ" & vbTab & dtNet & vbCrLf _
  18. & "ϵͳʱΪ" & vbTab & dtLocal1 & vbCrLf _
  19. & "׼ʱ" & vbTab & lngOffset1 & "" & vbCrLf & vbCrLf _
  20. & "У׼" & vbCrLf _
  21. & "׼ʱΪ" & vbTab & dtNet & vbCrLf _
  22. & "ϵͳʱΪ" & vbTab & dtLocal2 & vbCrLf _
  23. & "׼ʱ" & vbTab & lngOffset2 & ""
  24. Else
  25. strMessage =  "У׼" & vbCrLf _
  26. & "׼ʱΪ" & vbTab & dtNet & vbCrLf _
  27. & "ϵͳʱΪ" & vbTab & dtLocal1 & vbCrLf _
  28. & "׼ʱ" & vbTab & lngOffset1 & ""
  29. End If
  30. WScript.Echo strMessage
  31. End Sub
  32. '************************************************************************
  33. 'ȡָHTTPʱ
  34. '************************************************************************
  35. Function GetNetTime(ByVal Url)
  36.     Dim Bias, DateLine 'ʱƫƣӣ
  37.     Dim dtGMT, dtLocal, dtBegin
  38. On Error Resume Next
  39.     With CreateObject("WScript.Shell")
  40. '[ActiveTimeBias]:üֵ洢ǰϵͳʱԸα׼ʱƫƣԷΪλ
  41. '[Bias]:üֵ洢ǰʱԸα׼ʱƫƣԷΪλ
  42. Bias = .RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
  43.     End With
  44.     With CreateObject("Microsoft.XMLHTTP")
  45. dtBegin = Now()
  46.     .Open "POST", Url, False
  47.     .Send
  48. If Err.Number = 0 Then
  49. dtGMT = Split(Replace(.getResponseHeader("Date"), " GMT", ""), ",")(1)
  50. If IsDate(dtGMT) Then
  51. dtLocal = DateAdd("n", -CLng(Bias), CDate(dtGMT)) 'ʱ䣺GMT+8
  52. dtLocal = DateAdd("s", DateDiff("s", dtBegin, Now()), dtLocal) 'ʱ
  53. GetNetTime = dtLocal
  54. End If
  55. End If
  56.     End With
  57. End Function
  58. '************************************************************************
  59. '趨Եʱ
  60. '************************************************************************
  61. Function SetDateTime(ByVal dt1)
  62. Dim WmiService, ComputerName, OSList, OSEnum, OS, DateTime
  63. ComputerName = "."
  64. Set WmiService = GetObject("winmgmts:{impersonationLevel=impersonate, (Systemtime)}!//" + ComputerName + "/root/cimv2")
  65. Set OSList = WmiService.InstancesOf ("Win32_OperatingSystem")
  66. Set DateTime = CreateObject("WbemScripting.SWbemDateTime")
  67. For Each OSEnum In OSList
  68. DateTime.Value = OSEnum.LocalDateTime
  69. DateTime.Year = Year(dt1)
  70. DateTime.Month = Month(dt1)
  71. DateTime.Day = Day(dt1)
  72. DateTime.Hours = Hour(dt1)
  73. DateTime.Minutes = Minute(dt1)
  74. DateTime.Seconds = Second(dt1)
  75. If (OSEnum.SetDateTime(DateTime.Value) <> 0) Then
  76. 'WScript.Echo "棺ϵͳʱʧܣ"
  77. SetDateTime = False
  78. Else
  79. 'WScript.Echo "ʾóɹǰʱ䣺" & DateTime.GetVarDate()
  80. SetDateTime = True
  81. End If
  82. Next
  83. End Function
  84. '************************************************************************
  85. 'ʼ RunAsAdminX64 For Win10 x64
  86. '************************************************************************
  87. Function RunAsAdminX64()
  88. Dim wso, fso, dwx, sSFN, sSD32, sSF32, vArg, sArgs, oShell, sDWX
  89. Set wso = CreateObject("WScript.Shell")
  90. Set fso = CreateObject("Scripting.filesystemobject")
  91. RunAsAdminX64 = False
  92. 'ȡ WSH
  93. For Each vArg In WScript.Arguments
  94. sArgs = sArgs & " " & """" & vArg & """"
  95. Next
  96. 'ȡ 32 λ WSH Ŀ¼
  97. sSFN = fso.GetFile(WScript.FullName).Name
  98. sSD32 = wso.ExpandenVironmentStrings("%windir%\SysWOW64")
  99. If Not fso.FileExists(sSD32 & "\" & sSFN ) Then
  100. sSD32 = wso.ExpandenVironmentStrings("%windir%\System32")
  101. End If
  102. ' 32 λ WSH
  103. If UCase(WScript.FullName) <> UCase(sSD32 & "\" & sSFN) Then
  104. wso.Run sSD32 & "\" & sSFN & " """ & WScript.ScriptFullName & """" & sArgs, 1, False
  105. WScript.Quit
  106. End If
  107. 'ԹԱȨ WSH
  108. If Not WScript.Arguments.Named.Exists("ADMIN") Then
  109. Set oShell = CreateObject("Shell.Application")
  110. oShell.ShellExecute WScript.FullName, """" & WScript.ScriptFullName & """ " & sArgs & " /ADMIN:1 ", "", "runas", 6
  111. WScript.Quit
  112. End If
  113. End Function
ƴ
ǧˮǧ¡ǧˮӳǧƣ졣    http://yu2n.qiniudn.com/

TOP

ˣл¥İֻͨwin7 64 ΢ٷ档
л¥ģеүͨwin7 64 ˹˾档

TOP

yu2n 2019-5-26 12:41 ༭

2019.05.26  ѸʱԴվΪʱԴ (Զ HTTP ޸Ĵе http://www.microsoft.com )

Js Ҳˡ
  1. //ļƣSyncNetTime2.js
  2. //˵ͬʱʱ
  3. //ʹ÷Cscript.exe //nologo SyncNetTime.js
  4. //Իϵͳ Win10 x64 ʱ 18/1/15 û Yu2n
  5. //ݣFix ȡʱ䣬 HTTP SERVER HEADER
  6. //ԹԱ
  7. function GetSystemVersion() {
  8. var os = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem");
  9. for (var e = new Enumerator(os); ! e.atEnd(); e.moveNext()) {
  10. var v = e.item().Version;
  11. var ss = v.split('.');
  12. return ss[0] + ss[1];
  13. }
  14. return - 1;
  15. }
  16. if (GetSystemVersion() >= 60) {
  17. var cmd = WScript.ScriptFullName;
  18. if (cmd.substring(cmd.length - 3) != ".jS") {
  19. var Shell = new ActiveXObject("Shell.Application");
  20. Shell.ShellExecute("wscript.exe", "\"" + cmd.substring(0, cmd.length - 3) + ".jS\"", "", "runas", 1);
  21. WScript.Quit(0);
  22. }
  23. }
  24. //ȡʱ䣬 HTTP SERVER HEADER
  25. var getNetDate = function() {
  26. var dtGMT = '';
  27. try{
  28. var http = new ActiveXObject("Microsoft.XMLHTTP");
  29. http.open("POST", "http://www.microsoft.com?rnd=" + (new Date()), false);
  30. http.send();
  31. dtGMT = http.getResponseHeader("Date");
  32. if (dtGMT != '') {
  33. return new Date(dtGMT);
  34. } else {
  35. WScript.Echo("棺ȡʱʧܣ")
  36. WScript.Quit(0);
  37. };
  38. }catch(e){};
  39. };
  40. //ʱ
  41. function ChangeDate()
  42. {
  43. var WmiService, ComputerName, OSList, OSEnum, OS, DateTime;
  44. ComputerName = ".";
  45. WmiService = GetObject ("winmgmts:{impersonationLevel=impersonate, (Systemtime)}!//" + ComputerName + "/root/cimv2");
  46. OSList = WmiService.InstancesOf ("Win32_OperatingSystem");
  47. DateTime = new ActiveXObject ("WbemScripting.SWbemDateTime");
  48. OSEnum = new Enumerator (OSList);
  49. for ( ; !OSEnum.atEnd(); OSEnum.moveNext())
  50. {
  51. OS = OSEnum.item();
  52. var dtNewDate = getNetDate(); //ȡʱ
  53. DateTime.Value = OS.LocalDateTime;
  54. DateTime.Year = dtNewDate.getFullYear();
  55. DateTime.Month = dtNewDate.getMonth() + 1;
  56. DateTime.Day = dtNewDate.getDate();
  57. DateTime.Hours = dtNewDate.getHours();
  58. DateTime.Minutes = dtNewDate.getMinutes();
  59. DateTime.Seconds = dtNewDate.getSeconds();
  60. if (OS.SetDateTime(DateTime.Value) != 0) {
  61. WScript.Echo("棺ϵͳʱʧܣ");
  62. } else {
  63. WScript.Echo("ʾóɹǰʱ䣺" + new Date(DateTime.GetVarDate()).toLocaleString());
  64. };
  65. }
  66. }
  67. ChangeDate();
  68. WScript.Quit(0);
ƴ
ǧˮǧ¡ǧˮӳǧƣ졣    http://yu2n.qiniudn.com/

TOP

citygun 2019-4-24 13:51 ༭
Js Ҳˡ
yu2n 2017-2-10 23:38



  ֮ǰһֱòƷַб仯ʧЧˡĿǰĵַhttp://time1903.beijing-time.org/time.asp

TOP

ظ 13# citygun


    ѸʱԴվΪʱԴ
ǧˮǧ¡ǧˮӳǧƣ졣    http://yu2n.qiniudn.com/

TOP

ظ 14# yu2n


    һֱjsܷãлдôõĽű

TOP

б