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:
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
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