I'm trying to write a batch file that checks the system time and date. I would like it to check over the internet. I have this part. But thinking it should do the date part. But it only does the time if the date is correct
@echo off
w32tm /query /peers
net stop w32time
net start w32time
w32tm /resync /nowait
EOF
I do run the batch file as a administrator. Can someone help me with the date part of this. Thank you for taking the time to read this post. Any info would be a get help. Thank you
You have the NET TIME statement, but surely you don't have XP or a Lower OS, so that statement is already deprecated. For higher versions, therefore, using W32TM is a time management service that also serves to diagnose system problems.
How to synchronize the time and date from CMD?
Run a console as Administrator.
Start the service: net start w32time
Check its status: w32tm /query /peers
Synchronize the time and date: w32tm /resync /nowait
You can also change the specific time and date of a computer on the network with: net time \\DOMAIN /set
With this, you can now create the Batch script you need.
On the other hand, for more information, I share the source: https://learn.microsoft.com/.../windows.../ff799054(v=ws.11)
we push this batch file across networks US and canada via our rmm software
Hope it helps
@echo off
w32tm /query /peers
sc config w32time start= auto
w32tm /config /syncfromflags:manual /manualpeerlist:"0.us.pool.ntp.org,1.us.pool.ntp.org,2.us.pool.ntp.org,3.us.pool.ntp.org"
w32tm /config /reliable:yes
net stop w32time
net start w32time
w32tm /resync /nowait
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With