Home > other >  How to automatically sync Date & Time in windows?
How to automatically sync Date & Time in windows?

Time:09-17

I would like to write a .bat file that I can schedule with Task Scheduler in Windows. The script should open the time settings and automatically click the sync option like so:

enter image description here

So far I was able to open this window by using the following line of code:

start ms-settings:dateandtime

However I do not know how to click on the Sync now button.

Do you know a smart and elegant way to achieve this task? Feel free to suggest a completely different approach if the final result is the same.

CodePudding user response:

w32tm /resync Must be run by the administrator or else you get a denied message

For more details on other options see enter image description here

On a domain then use

w32tm /domain

want to use a different server than default ? then replace time.server.com

w32tm /config /update /manualpeerlist:time.server.com

enter image description here

see https://www.ntppool.org/en/use.html

  • Related