windows - 如何在 Windows 中自动同步日期和时间?
问题描述
我想编写一个 .bat 文件,我可以在 Windows 中使用任务计划程序进行计划。该脚本应打开时间设置并自动单击同步选项,如下所示:
到目前为止,我可以使用以下代码行打开此窗口:
start ms-settings:dateandtime
但是我不知道如何单击“立即同步”按钮。
你知道完成这项任务的聪明而优雅的方法吗?如果最终结果相同,请随意提出完全不同的方法。
解决方案
w32tm /resync
必须由管理员运行,否则您会收到拒绝消息
有关其他选项的更多详细信息,请参阅https://docs.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings
w32tm /resync
Sending resync command to local computer
The following error occurred: Access is denied. (0x80070005)
然后在域上使用
w32tm /domain
想要使用与默认不同的服务器?然后替换time.server.com
w32tm /config /update /manualpeerlist:time.server.com
推荐阅读
- go - 如何将 row.Scan() int32 放入 Golang gRPC protobuf Enum 字段?
- linux-kernel - 如何通过从用户空间提供文件指针来从内核空间接收文件指针
- scala - 更新 Spark 数据框以从另一个数据框填充数据
- r - R:调用包中的导入函数时出错
- python - 在 Django Rest Framework 中更新和删除用户
- r - R 无法读取我的 CSV 文件的随机列
- python - 如何将此json多列表写入python pandas中的单独列
- php - php通过mysqli连接mysql数据库
- php - php 从另一个目录执行 python 脚本
- mysql - 安装后立即拒绝用户'root'@'localhost'的访问