Configure W32Time (NTP) on a Standalone Windows Box

How to setup the NTP client on standalone Windows boxes. And an explanation of the various registry settings. Use powershell and the command line tools to setup NTP.

NTP is Fun

Synchronized time is important and very easy to setup. This article is for setting up the NTP clients on a Windows 10 box. This is NOT for a box that is part of an active directory domain. This is only for standalone boxes. Or in other words it is for your home computer not your business computers. NTP uses 123/UDP.

Links to the Official Docs

This article only touches the surface of NTP. It is a pretty basic service and easy to setup. But it can get rather complicated if you deep dive into the subject. Note that the basic NTP client does not support NTP authentication (NTP keys). You need to use active directory to enable authentication.

Registry Settings

I spent some time looking up the various registry settings related to NTP. A typical home user will not need to change most of these settings. This is just a reference. These settings are used when you configure an Active Directory Domain Controller to serve as a NTP server. Most of these settings are hexadecimal (base 16 // 0-9 A-F). You can enter combine options by adding together the values. If you don't understand binary or converting from decimal to hex or decimal, don't play with any of these settings.

Main Registry Directory

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time

Refer to the Windows Time Service Tools and Settings link above for more information about the various registry settings.

W32Time\Parameters\NtpServer

This is a space delimited listing of each NTP server the client will query. Each NTP server can be listed as a hostname or an IP address. Each NTP server needs to be followed by a comma and the appropriate hexadecimal flag.

  • 0x1 - Use the special poll interval set in the registry instead of the default value. The default is 7 days (604,800 // 0x00093a80)
  • 0x2 - Use this source only as a fallback if all other time sources have failed.
  • 0x4 - Send request as SymmetricActive Mode. This is for Windows servers.
  • 0x8 - Send NTP queries in client mode

Most home users will use '0x8'. If you want to query the NTP servers more frequently then use '0x9' which is '0x8 + 0x1'.

\TimeProviders\NtpClient\SpecialPollInterval

This determines in seconds how often the computer will poll or query the NTP servers. This is an optional change. If you are uncomfortable changing registry settings do not use this option. You must set the '0x1' flag in the NtpServer settings to use this feature.

The default value is every 7 days. But W32Time will poll on a floating interval, based on the quality of the time samples being returned by the time source. In this example I will be using the public NTP pool servers. And since microsecond accuracy isn't that important for a home user I will be querying the servers every 12 hours. (sec = 43,200 // hex = 0x000a8c0)

IMPORTANT: In build 1702 SpecialPollInterval is contained by the \Config\MinPollInterval and \Config\MaxPollInterval registry values. I am still on build 1607. I need to verify these settings once my computer is finally updated.

\Parameters\Type

This entry indicates from which peers to accept synchronization.

  • NoSync - The time service does not synchronize with other sources.
  • NTP - The time service synchronizes from the servers specified in the NtpServer registry key. (Our required value and the default value for standalone boxes.)
  • NT5DS - The time service synchronizes from the domain hierarchy.
  • AllSync - The time service uses all the available synchronization mechanisms.

W32Time\Config\AnnounceFlags

This entry controls whether this computer is marked as a reliable time server. A computer is not marked as reliable unless it is also marked as a time server. The default value for domain members and standalone clients is 10. (hex = a)

  • 0x0 - Not a time server
  • 0x1 - Always a time server
  • 0x2 - Automatic time server
  • 0x4 - Always reliable time server
  • 0x8 - Automatic reliable time server.

As stated above the default value is 10 (0x8 + 0x2). This means our client is an automatic reliable time server and an automatic time server.

W32Time\Start

This is one of three registry settings that describe how the W32Time process will start. The other two are 'W32Time\Type' and 'W32Time\DelayedAutostart'. All three settings are DWORD data types. The start setting specifies how the service is loaded or started. If the service is a Win32 service, the value of this entry must be 2, 3, or 4. This entry is not used for network adapters. The W32Time service has a start value of 2 (automatic).

Value Meaning
0 Boot (loaded by the kernel loader). Components of the driver stack for the boot (startup) volume must be loaded by the kernel loader.
1 System (loaded by I/O subsystem). Specifies that the driver is loaded at kernel initialization.
2 Automatic (loaded by the Service Control Manager). Specifies that the service is loaded or started automatically.
3 Manual. Specifies that the service does not start until the user starts is manually, such as by using Device Manager.
4 Disabled. Specifies that the service should not be started.

W32Time\Type

Identifies the type of service represented by the subkey. The W32Time service has a type value of 32.

Value Meaning
1 A kernel-mode device driver.
2 A file system driver.
4 A set of arguments for an adapter.
8 A file system driver service, such as a file system recognizer.
16 A Win32 program that runs in a process by itself. This type of Win32 service can be started by the service controller.
32 A Win32 program that shares a process. This type of Win32 service can be started by the service controller.
272 A Win32 program that runs in a process by itself (like Type16) and that can interact with users.
288 A Win32 program that shares a process and that can interact with users.

W32Time\DelayedAutostart

This subkey is added when an automatic process is set to start at boot but with a delayed start. The Set-Service cmdlet cannot set a process to a delayed start. The 'sc config' command line tool does allow this option. Use the commands below to create this subkey if necessary.

  • $RegRoot ="HKLM:\SYSTEM\CurrentControlSet\Services\W32Time"
  • Set-ItemProperty -Path $RegRoot -Name "DelayedAutostart" -Value 1 -Type DWORD

Use the command below to verify all of the settings.

Get-ItemProperty -Path $RegRoot

To just see one of the subkeys and get rid of the various PS values use the 'Format-List' cmdlet. This can be shortened to 'FL'. I am not adding the '-Name' flag to the 'Item-Property' cmdlet as it is not necessary.

Get-ItemProperty -Path $RegRoot |FL -Property DelayedAutostart,Start,Type

Setup via Powershell

It is very simple to setup NTP using the old command line tools. But Microsoft is moving away from those tools. Powershell is the future. Here the the commands to setup everything using Powershell. This assumes you are running Powershell as an administrative user by right clicking and running as an administrator. Everyone should be running Windows as a standard user and not an administrative user. Keep in mind that powershell is not case sensitive.

Start and Stop a Service

Use 'Start-Service w32time', 'Stop-Service w32time', and 'Get-Service w32time' to start and stop the service. And then to verify the status of the service.

  • To Start = Start-Service w32time (net start w32time)
  • To Stop = Stop-Service w32time (net stop w32time)
  • Status = Get-Service w32time

View the Startup Mode

A way to verify the startup mode for a particular service.

PS > Get-WmiObject -Class Win32_Service -Filter "Name = 'W32Time'"

ExitCode  : 0
Name      : W32Time
ProcessId : 1076
StartMode : Auto
State     : Running
Status    : OK

Setup the NTP Server List

This example uses '0x9'. Change this to '0x8' if you don't want to change the SpecialPollInterval registry value. The command is broken up over several lines using the backtick ( ` ) to make it easier to understand. This doesn't paste well into powershell. You need to remove the backticks and reduce this to a single line before pasting into powershell.

  • $RegRoot ="HKLM:\SYSTEM\CurrentControlSet\Services\W32Time"
  • $MyNTP ="0.pool.ntp.org,0x9 1.pool.ntp.org,0x9 2.pool.ntp.org,0x9 3.pool.ntp.org,0x9"

Set-ItemProperty -Path "$RegRoot\Parameters" `
-Name NtpServer -Value "$MyNTP"

Set the Service for Delayed Autostart

As stated above the 'Set-Service' cmdlet cannot set a service to delayed autostart. I am not sure if the 'DelayedAutostart' registry setting is set to '1' by default for the W32Time service. But it is easy to check first.

Get-ItemProperty -Path $RegRoot |FL -Property DelayedAutostart,Start,Type

The output should look like the following.

DelayedAutostart : 1
Start            : 2
Type             : 32

To set the start type to automatic (2) run the following command.

Set-Service -Name w32time -StartupType Automatic

Run the following command to create the 'DelayedAutostart' registry key.

  • $RegRoot ="HKLM:\SYSTEM\CurrentControlSet\Services\W32Time"
  • Set-ItemProperty -Path $RegRoot -Name DelayedAutostart -Value 1 -Type DWORD

You can also use the 'sc config' command line tool within powershell.

sc config w32time start= delayed-auto

Adjust the SpecialPollInterval

This step is truly unnecessary for home users. Home users should use the '0x8' flag on the NTP server list. But it is easy enough to change. The setting is in seconds. One hour (3600) is 60 seconds times 60 minutes. Multiply 3600 by X number of hours to get your desired hour value. Multiply 3600 by 24 and then by X number of days to get the number of seconds for that desired day value.

  • 7 Days = 604800 (Default Value)
  • 12 Hours = 43200
  • 4 Hours = 14400
  • 1 Hour = 3600
  • 15 Minutes = 900

Run the following commands to set the value to 12 hours (43200 seconds).

  • $RegRoot ="HKLM:\SYSTEM\CurrentControlSet\Services\W32Time"
  • Set-ItemProperty -Path $"RegRoot\TimeProviders\NtpClient" -Name SpecialPollInterval -Value 43200

Resync W32Time

Now that everything has been setup it is time to resync W32Time. This command is a standard command line tool. But it can be run within the powershell environment. Like the other commands run above you need to be an administrative user to run this command. I am adding the '/rediscover' flag to force W32Time to re-read the configuration information.

w32tm /resync /rediscover

The Easy Setup

If you are just a normal user it is a lot easier to use the old command line tools. Microsoft is trying to deprecate these tools. But it won't happen anytime soon. You must run the command window as an administrative user.

  • net start w32time

The following command is one line broken up by carrots (^) to make it more legible.

  • w32tm /config /update ^
    /manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0x8 ^
    2.pool.ntp.org,0x8 3.pool.ntp.org,0x8" ^
    /syncfromflags:MANUAL
  • sc config w32time start= delayed-auto
  • w32tm /resync