Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I synchronize a windows PC time to a NTP server using a batch script?

share|improve this question

4 Answers 4

You can use the Net Time command to do this:

Net Time /SETSNTP:time-a.nist.gov

This will set your machine to use the external server specified for its time server.

If you wish to set the machine to use an internal time server, you can use this command:

NET TIME \\TIMESRV /SET /YES
share|improve this answer

If you wish to use NTP you should really use it properly and install an NTP daemon. It will try keep your clock in sync using regular clock skew rather than jumping it at arbitrary times.

You can get a good Windows port of the standard NTPD from here.

share|improve this answer

You don't need to use a batch script.

See my answer here for some info on NTP in Windows.

share|improve this answer

If you have AD you don't need to do this, so long as the client is properly set up (i.e. no time server is set) it will automatically sync with the doamin hierarchy.

If you don't have AD you need to look at the NET TIME or W32TM commands.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.