36

I am working on windows 7. I can sync time of win7 from a ntp linux server manually. How can I do that in command prompt. So I can run it on windows startup. And windows task plan not work for me. The time should be like this:

Linux server -->  windows 7.

Any one knows that? Thank you. I can read msdn.

Nick Dong
  • 3,638
  • 8
  • 47
  • 84

4 Answers4

62
net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"
net start w32time
w32tm /config /update
w32tm /resync /rediscover

.BAT Sample File: https://gist.github.com/thedom85/dbeb58627adfb3d5c3af

I also recommend this program: http://www.timesynctool.com/

Sadeq Dousti
  • 3,346
  • 6
  • 35
  • 53
Domenico Zinzi
  • 954
  • 10
  • 18
  • 5
    thanks for the `timesynctool` ref, just what i needed. – kmonsoor May 23 '16 at 10:25
  • 1
    Solved my problem thanks. I have a workstation that is domain joined so time settings "Are managed by your organisation" but is is being used away from the domain at the moment. – Nicolas Aug 14 '18 at 15:31
34

Use net time net time \\timesrv /set /yes

after your comment try this one in evelated prompt :

w32tm /config /update /manualpeerlist:yourtimerserver
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
10

If you just need to resync windows time, open an elevated command prompt and type:

w32tm /resync

C:\WINDOWS\system32>w32tm /resync 
Sending resync command to local computer 
The command completed successfully.
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
9

While the w32tm /resync in theory does the job, it only does so under certain conditions. When "down to the millisecond" matters, however, I found that Windows wouldn't actually make the adjustment; as if "oh, I'm off by 2.5 seconds, close enough bro, nothing to see or do here".

In order to truly force the resync (Windows 7):

  1. Control Panel -> Date and Time
  2. "Change date and time..." (requires Admin privileges)
  3. Add or Subtract a few minutes (I used -5 minutes)
  4. Run "cmd.exe" as administrator
  5. w32tm /resync
  6. Visually check that the seconds in the "Date and Time" control panel are ticking at the same time as your authoritative clock(s). (I used watch -n 0.1 date on a Linux machine on the network that I had SSH'd over into)

--- Rapid Method ---

  1. Run "cmd.exe" as administrator
  2. net start w32time (Time Service must be running)
  3. time 8 (where 8 may be replaced by any 'hour' value, presumably 0-23)
  4. w32tm /resync
  5. Jump to 3, as needed.
starlocke
  • 3,407
  • 2
  • 25
  • 38