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.

4 Answers 4

65
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/

1
  • 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
    Commented Aug 14, 2018 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
10
  • service not start @Kayasax I have run sc start w32time. Windows time service already started.
    – Nick Dong
    Commented Apr 4, 2014 at 12:19
  • It runs successfully without error. But time was not change. When I run time /t. It make me crazy. @Kayasax
    – Nick Dong
    Commented Apr 4, 2014 at 12:35
  • 3
    @Kayasax w32tm /resync says "The computer did not resync because the required time change was too big." as my CMOS battery is dead and my computer clock resets on every boot at 1/1/2000 12:00 AM. Any help?
    – Never Quit
    Commented Nov 4, 2015 at 16:52
  • 2
    @Kayasax Found solution as per blog.bruteforcetech.com/archives/911 , do not forget to restart W32Time service net stop W32Time then retry w32tm /resync
    – Never Quit
    Commented Nov 4, 2015 at 17:12
  • 2
    Also if you are on a VM turn off the VMICTimeProvider with the following registry tweak! serverfault.com/a/490619/169771
    – Arvo Bowen
    Commented Jun 28, 2017 at 20:13
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.
0
10

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.

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