Windows server 2008 时间同步脚本
Windows server 2008 时间同步脚本,win7 下测试可用。

@ Author:jackq.com
echo Windows Registry Editor Version 5.00 >>%temp%\time_tmp.reg
@ 更改时间同步频率为每15分钟一次
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient] >>%temp%\time_tmp.reg
echo “DllName”=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,\ >>%temp%\time_tmp.reg
echo 74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,77,\ >>%temp%\time_tmp.reg
echo 00,33,00,32,00,74,00,69,00,6d,00,65,00,2e,00,64,00,6c,00,6c,00,00,00 >>%temp%\time_tmp.reg
echo “Enabled”=dword:00000001 >>%temp%\time_tmp.reg
echo “InputProvider”=dword:00000001 >>%temp%\time_tmp.reg
echo “AllowNonstandardModeCombinations”=dword:00000001 >>%temp%\time_tmp.reg
echo “CrossSiteSyncFlags”=dword:00000002 >>%temp%\time_tmp.reg
echo “ResolvePeerBackoffMinutes”=dword:0000000f >>%temp%\time_tmp.reg
echo “ResolvePeerBackoffMaxTimes”=dword:00000007 >>%temp%\time_tmp.reg
echo “CompatibilityFlags”=dword:80000000 >>%temp%\time_tmp.reg
echo “EventLogFlags”=dword:00000001 >>%temp%\time_tmp.reg
echo “LargeSampleSkew”=dword:00000003 >>%temp%\time_tmp.reg
echo “SpecialPollTimeRemaining”=hex(7):74,00,69,00,6d,00,65,00,2e,00,77,00,69,00,6e,\ >>%temp%\time_tmp.reg
echo 00,64,00,6f,00,77,00,73,00,2e,00,63,00,6f,00,6d,00,2c,00,37,00,62,00,34,00,\ >>%temp%\time_tmp.reg
echo 30,00,65,00,66,00,63,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ >>%temp%\time_tmp.reg
echo 00,00,00,00,00,00,00 >>%temp%\time_tmp.reg@ 更改时间同步服务器为time.nist.gov
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters] >>%temp%\time_tmp.reg
echo “ServiceDll”=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,\ >>%temp%\time_tmp.reg
echo 00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\ >>%temp%\time_tmp.reg
echo 77,00,33,00,32,00,74,00,69,00,6d,00,65,00,2e,00,64,00,6c,00,6c,00,00,00 >>%temp%\time_tmp.reg
echo “ServiceMain”=”SvchostEntry_W32Time” >>%temp%\time_tmp.reg
echo “ServiceDllUnloadOnStop”=dword:00000001 >>%temp%\time_tmp.reg
echo “Type”=”NTP” >>%temp%\time_tmp.reg
echo “NtpServer”=”time.nist.gov,0×9″ >>%temp%\time_tmp.reg@regedit /s %temp%\time_tmp.reg
@del /f /s /q %temp%\time_tmp.reg@ 重启windows时间服务并立即同步系统时间
net stop w32time && net start w32time
w32tm /resync
exit
如果不喜欢系统自带的time.nist.gov来同步时间, 也可以使用ntp.api.bz 同步时间。
附:Linux环境时间同步方法
ntpdate 210.72.145.44 (中国国家授时中心IP服务器地址)
加入到cron中可定时对时,加入ntpd中可更精确对时。










