
把下面的命令保存为bat批处理文件,以管理员方式运行,即可一键完成。
:: 设置NtpServer的Enabled值为1
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" /v "Enabled" /t REG_DWORD /d 1 /f
:: 设置Config的AnnounceFlags值为5
reg add "HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /v "AnnounceFlags" /t REG_DWORD /d 5 /f
:: 设置Windows Time服务启动类型为自动
sc config W32Time start= auto
:: 启动Windows Time服务
net start W32Time
::验证配置
w32tm /stripchart /computer:127.0.0.1 /dataonly /samples:5
:: 创建新的入站规则:允许UDP 123端口
netsh advfirewall firewall add rule name="Allow NTP (UDP 123)" dir=in action=allow protocol=UDP localport=123 profile=any enable=yes description="允许NTP协议通过UDP 123端口"
echo 配置完成!
pause
976

被折叠的 条评论
为什么被折叠?



