2个回答
展开全部
以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,并以管理员身份运行
/*&cls&echo off
rem 获取网络时间对本地电脑进行时间同步
set #=Any question&set 唤态@=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
for 和扰源/f "tokens=1*" %%a in ('cscript -nologo -e:jscript "%~f0"') do (
echo;%%a %%b
date %%a
time %%b
)
echo;%#% +%$%%$%/%@% %z%
pause
exit
*/
function add(z){return Number(z)<10?'0'+z:z;}
var req=null, now=null;
var mx=['MSXML2.ServerXMLHTTP.6.0','MSXML2.ServerXMLHTTP.3.0','MSXML2.ServerXMLHTTP'];
var host=['moc+udiab+www##:sptth','moc+oaboat+www##:sptth','moc+vtcc+www##:sptth'];
for(var i=0;i<mx.length;i++){
try{
req=new ActiveXObject(mx[i]);
break;
}catch(e){}
}
if(req==null){WSH.StdErr.WriteLine("Can't build XMLHTTP object");WSH.Quit();}
for(var i=0;i<host.length;i++){
try{
url=host[i].replace(/#/g,'/').split('李枣').reverse().join('').replace(/\+/g,'.');
req.open('GET', url, false);
req.send();
var gmt=req.getResponseHeader('Date');
if(gmt !=''&&gmt !=null){
WSH.StdErr.WriteLine(gmt);
now=new Date(gmt);
break;
}
}catch(err){WSH.StdErr.WriteLine(err.message);}
}
if(now !=null){
var y=now.getFullYear(),m=now.getMonth()+1,d=now.getDate();
var hh=now.getHours(),mm=now.getMinutes(),ss=now.getSeconds();
WSH.echo(y+'-'+add(m)+'-'+add(d)+' '+add(hh)+':'+add(mm)+':'+add(ss));
}else{WSH.StdErr.WriteLine('Failed to get Internet Time');}
WSH.Quit();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |