- @echo off
- cls
- color 2f
- cd /d %~dp0
- Echo.&&Echo.正在与Internet时间服务器同步……&&Echo.===================================================
- wget -N http://weasel.jgxx.com/wsqbbs/time.php >nul 2>nul
- title 瓦斯曲-同步时间服务器工具
- for /f "tokens=1,2 " %%i in (time.php) do date %%i &&time %%j
- for /f "tokens=1,2 " %%i in (time.php) do echo 同步成功!!&& echo 服务器日期 %%i 系统日期 %date% &&echo 服务器时间 %%j 系统时间 %time%
- del /f /s /q time.php >nul 2>nul
- Echo.==================================================&&Echo.按任意键退出!!&&pause>nul 2>nul
复制代码
- @echo off
- wget -N http://www.appinn.com/servertime.php
- for /f "tokens=1,2 " %%i in (servertime.php) do date %%i &&time %%j
复制代码
- //这是一段在网上找到的系统时间自动更新JS脚本,任意Web服务器都可以用来协对时间而且也不用vb来改时间,保存为*.js点击运行即可
- //get HTTP Date: response from server, return approximate dateVal object
- function getServerDate(serverHttpAddress, httpProxyAddress)
- {
- var xmlHttp = new ActiveXObject("msxml2.xmlhttp");
- if(httpProxyAddress)
- {
- setProxy(2,proxyHttpAddress.replace("http://",""));
- }
- xmlHttp.open("GET", serverHttpAddress, 0);
- ts=(new Date()).getTime();
- WScript.Echo("Start time: " + ts);
- xmlHttp.send();
- tr=new Date();
- WScript.Echo("End time: " + tr.getTime());
- WScript.Echo("Server Time: " + Date.parse( xmlHttp.getResponseHeader('Date')));
- //Thu, 1 Jan 2009 09:47:01 GMT
- tr.setTime(Date.parse( xmlHttp.getResponseHeader('Date')) + ((new Date()).getTime() - ts)/2);
- //1230805540107
- WScript.Echo("debug time: " + tr)
- return tr;
- //}
- //catch(e)
- //{
- // return 0
- //}
- }
-
- //set system time to dateString
- //http://www.microsoft.com/technet/scriptcenter/topics/networking/08_atnc_advanced.mspx
- //http://www.microsoft.com/technet/scriptcenter/guide/sas_wmi_fvwp.mspx?mfr=true
- //20030327073509.519000+480
- function setSystemDate(dateString)
- {
- WScript.Echo("End time: " + dateString);
- var oSvc = GetObject("winmgmts:\\\\.\\root\\cimv2");
- oSvc.Security_.Privileges.AddAsString("SeSystemTimePrivilege", 1);
- var e = new Enumerator(oSvc.execQuery("select * from win32_OperatingSystem", "WQL", 32));
- //for (;!e.atEnd();e.moveNext())e.item().SetDateTime(dateString);
- }
-
- //generating the right WMI DATETIME fields
- with(getServerDate("http://www.google.com/")) //和哪一个HTTP服务器进行同步
- {
- setSystemDate("" +
- getUTCFullYear() +
- (getUTCMonth()<9?"0"+(getUTCMonth()+1):(getUTCMonth()+1)) +
- (getUTCDate()<9?"0"+getUTCDate():getUTCDate()) +
- (getUTCHours()<9?"0"+getUTCHours():getUTCHours()) +
- (getUTCMinutes()<9?"0"+getUTCMinutes():getUTCMinutes()) +
- (getUTCSeconds()<9?"0"+getUTCSeconds():getUTCSeconds()) +
- ".******+***");
- }
复制代码
|