设置NTP校时
作者:互联网
设置NTP校时-作为客户端
@echo off
rem 以管理员身份执行文件
rem 获取管理员权限
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 : :","","runas",1)(window.close)&&exit
rem 设置NTP服务器地址
w32tm /config /manualpeerlist:"time.pool.aliyun.com,0x9 ntp.tencent.com,0x9 ntp.ntsc.ac.cn,0x9" /syncfromflags:manual /reliable:yes /update
rem 设置轮询时间
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" /v "SpecialPollInterval" /t REG_DWORD /d 3600 /f
rem 重启时间服务
net stop w32time
net start w32time
rem 同步时间
w32tm /resync
rem 确保Windows Time服务启动类型设置为自动
rem (存疑)两个RPC服务都要打开,Remote Procedure Call (RPC) ,Remote Procedure Call (RPC) Locator
rem 检查防火墙入站规则123/UDP
pause
设置NTP校时-作为服务器
@echo off
rem 以管理员身份执行文件
rem 获取管理员权限
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 : :","","runas",1)(window.close)&&exit
rem 设置时间同步为NTP模式
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v "Type" /d "NTP" /f
rem 启用NTPServer服务
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" /v "Enabled" /t REG_DWORD /d 1 /f
rem 设置本机从外部时间源同步时间
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v "AnnounceFlags" /t REG_DWORD /d 5 /f
rem 重启时间服务
net stop w32time
net start w32time
rem 确保Windows Time服务启动类型设置为自动
rem (存疑)两个RPC服务都要打开,Remote Procedure Call (RPC) ,Remote Procedure Call (RPC) Locator
rem 检查防火墙入站规则123/UDP
pause
标签:NTP,校时,add,RPC,设置,rem,Services 来源: https://www.cnblogs.com/caishuaichao/p/16615661.html