以下
代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,以管理员身份运行/*&cls&echo offrem 获取网络
时间对本地电脑进行时间同步set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4title %#% +%$%%$%/%@% %z%for /f "tokens=1*" %%a in ('cscript -nologo -e:jscript "%~f0"') do (echo%%a %%bdate %%atime %%b)echo%#% +%$%%$%/%@% %z%pauseexit*/function add(z){return Number(z)<10?'0'+z:z}var mx=['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']var req=null,url=('moc+iqnait+emit##:ptth').replace(/#/g,'/')for(var i=0i<mx.lengthi++){try{req=new ActiveXObject(mx[i])break}catch(e){}}if(req==null){WSH.StdErr.WriteLine("Can't build XMLHTTP object")WSH.Quit()}try{req.open('GET', url.split('').reverse().join('').replace(/\+/g,'.'), false)req.send()var m=req.ResponseText.match(/var \S+ ?= ?"(\d{13})"/)if(m){var tt=parseInt(m[1].substring(0, 10))var now=new Date(tt*1000)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")}}catch(e){WSH.StdErr.WriteLine(e.message)}WSH.Quit()
增加下面的代码, 获取Server的存取权限, 本地使用管理员权限运行.
@echo off
net use
/user:serveruser /password:serverpassword
@echo off
::这个意思是获取192.168.1.100时间
net time \\192.168.1.100
::这个意思是同步192.168.1.100时间
net time \\192.168.1.100 /set
评论列表(0条)