In one of my earlier post I talked about fixing Clock drift for a virtual machine that is not joined to a domain. It is located here.
The issue that I was running into was that my clock for some reason would get set back about a day and that would mess up my time that I submitted posts. For example, this post about me leaving Amazon was supposed to be on 1 March 2012, but it was posted a day earlier due to my clock drift issue.
People have recommended to me earlier that all you needed to do was change the existing Synchronize Time scheduled task so that it runs more frequently. From my experience that did not help. I even tried making that task run once a day and my clock still drifted. Upon my investigation, it appears that it would only make sure that the Windows Time service is running and if it’s already running then the task does nothing. It relies on the Windows Time service to actually performs the sync, which appeared to be about be once a week.
There is also the SpecialPollInterval setting under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient registry key settings, which I used to recommend a lot. (Please note this key has moved a few times between Windows versions) I got the impression that this setting would allow you to specify in minutes how often it should sync.
While modifying that registry value may update the “next sync time” displayed in the control panel, I have found it does *not* actually affect how frequently the clock is synced. Feel free to verify it yourself but my testing seems to confirm my verdict.
As far as I have observed, the registry value changes how often the time service wants to sync but only applies it when time service is actually running. When the time service sync is controlled by the Windows Task Scheduler (and not the registry value) then when the service runs it exits immediately after performing any required task from the job. After that the time service will not do anything (or run at all) until the Task Scheduler starts the task again.
Which gets to… how do we fix it?? (My favorite part of this topic) As you can tell from above there is a lot of information out there that can be misleading to fix the issue.
The W32tm.exe tool, with /resync argument, triggers a clock sync, provided the Windows Time service is running. (If you want to test it manually, note that the command requires administrator rights and that the service may need to be started.)
It’s easy to set up a scheduled task which ensures the Windows Time service is available and then runs W32tm.exe /resync once a day or as often as you like:
- Open Task Scheduler (Go to Administrative tools and it is on the menu or search in Control Panel).
- Find the Microsoft / Windows / Time Synchronization branch and click Create Task…
- Provide the task a name. I called mine Properly Synchronize Time.
- Set the new task to run as the LOCAL SERVICE user.
- Set it to run with highest privileges and to be configured for your OS version.
- Add a new Trigger.
- Set the task to run daily at the time you want, but it is best to run it right away. I also wanted mine to run every 10 minutes as well.
- The task will have two actions. Make sure they end up in the right order. The first action does the same as the original Synchronize Time task and ensures the Windows Time service is running. The second action makes the actual time sync happen.
- Add a new Action.
- Set the first action to start a program, which is C:\Windows\system32\sc.exe with arguments start w32time task_started
Set the second action to start a program, which is C:\Windows\system32\w32tm.exe with argument /resync
- Notice both actions are listed.
- Turn off the setting which makes the task only run on AC power. The task is very brief so there’s no reason to only run it when on battery power.
- Set the task to start only if a network connection is available.
- Set the task to run as soon as possible if its schedule is missed. (Other options are set by default.)
- To test that the task actually works, manually mess up your clock’s time and then right-click the task and select Run. Your clock’s time should be corrected or you can also wait 10 minutes if you scheduled your job like I did.
- You should also check the Date and Time control panel to ensure it is set to synchronize time via the Internet. (Note that the Date and Time control panel will still say the next synchronization is a week away. It only knows about its own schedule and doesn’t know about the task we just set up.)