NTPTime version 4.3

If you have a Windows computer and you want to keep its clock set accurately from time servers on the internet, you have come to the right place. NTPTime is a simple time setting client that runs on Windows NT/2000/XP as a service and Windows 95/98/ME as a hidden program. Both the executable and the source code are freely available.

This file was last updated on March 9th, 2010. The update was only to change the contents to reflect the forced move to comcast.net from att.net due to worldnet shutting down their personal web servers. The downloadable files linked to from here do not reflect these changes (I didn't feel like repackaging them - sorry :-).

This file was previously updated on April 30, 2004. If you think you might be looking at an old copy, you can check the master version at http://home.comcast.net/~tomhorsley/software/ntptime/ntptime.html.

Table of Contents

This document and the NTPTime program and source code are all Copyright © Tom Horsley, 1997-2004. All rights reserved. The right to unlimited distribution and use of this program is granted to anyone who agrees to keep the copyright notice intact and not alter the program.

Translation: You want changes in the program, make 'em yourself, but don't go distributing the new version with my name on it (or with your name on it either, since you didn't write most of it :-). If there are changes you would like to see distributed, by all means send 'em in to me, and if I like 'em I'll incorporate them in the next version.

Get Started Fast

For the impatient: First read about finding a time server. You will need to have one or more server names handy in the next step.

Download the file ntp43bin.zip. Unzip the files, open a command window, and cd to that directory. Run the ntpquick.bat script. If anything goes wrong, I'm afraid you will have to actually read more of this manual (sorry about that :-).

NTPTime Features

ntptime.exe is the main component of NTPTIme. It is an NTP client program. This means that it uses the internet to set the time on your computer by talking to a system somewhere out in the world which is running an NTP time server. There are many such servers available on the internet, and the installation section describes how to find one.

NTPTime runs as a service on Windows NT/2000/XP which must be installed by a user with administrator privileges (I have only tested it on NT 4.0 and XP, but it should work fine on 2000). On Windows 95/98/ME it runs as hidden window, and you will probably want to add it to your start menu or to the registry as a program to be run when the machine boots.

If you connect to the internet via dial up networking, NTPTime can be configured to lurk in the background until it notices you have an active internet connection, then talk to the server to set the time. This lurking (after much blood sweat and tears) will never trigger an autodial on your computer (I hope - Microsoft seems to keep "helpfully" making more and more events trigger autodialing). Instead, it waits for you to connect for some other reason, then asks for the time. If you actually want it to autodial, then don't tell it to wait for a dial up connection, and Windows will probably trigger the autodial when NTPTime tries to set the time.

If you don't like the idea of a background process cluttering up your system all the time, then you can configure it to set the time only once, then exit. This way it only clutters up your system until the first time you connect to the internet.

NTPTime can keep a log file showing when it adjusted the clock and how much it adjusted it by. This log will also record any errors which make the program exit, so the log is valuable if you are having trouble getting it to work.

ntptime.exe has a few command line options it will recognize:

--help Pop up a window with a summary of these options.
--noras Never install a dependency on the RAS service
--install Install ntptime.exe a service on windows NT/2000/XP
--installq Just like install, but does not popup a message on success (the quiet install option).
--uninstall Remove ntptime.exe as a windows NT/2000/XP service.
--uninstallq Just like uninstall, but does not popup a message on success.
--version Popup a window with version and copyright information.
--w95 Run as a Windows 95/98/ME hidden window (rather than a service) even when the current OS is Window NT/2000/XP.

ntptime.cpl is the control panel for NTPTime. It provides a graphical interface to edit all the parameters that control how NTPTime operates.

ntptray.exe is a new program in version 4.2 of NTPTime. If you like system tray icons, you can run ntptray.exe when you startup windows to monitor and control NTPTime.

ntpoke.exe has been rendered obsolete by the arrival of the ntptray.exe program in version 4.2. It is still incuded in the binary, but does nothing ntptray cannot also do.

A few other files are also included in the distribution:

ntpreg.reg A sample registry file. You can edit this and use it to install the registry entries without needing to run the control panel.
ntpstart.reg Registry file for installing ntptime.exe in the RunServices key so it will automatically run at startup on Windows 95/98/ME systems.
ntpxpcat.reg A registry file for use on Windows XP to install the control panel in the new XP Category view. May need some editing depending on where you install ntptime.cpl
sample1.bat A sample batch script sent to me by Jouni Aro for installing NTPTime as a service.
sample2.bat A different sample batch script from Peter Yasuda for remotely installing NTPTime as a service (this will need updating for the new registry keys that versions 4.0 and later need).
ntp.adm A sample group policy editor template from David Nemeth which system administrators may find handy for controlling access to the NTPTime control panel.
ntpquick.bat My own attempt at a batch script to install NTPTime.

NTPTime Control Panel

The following sections describe each page of the NTPTime control panel. The control panel is really just a simple way to edit the registry entries which are described following the control panel (for those who really want to know the nitty gritty details, or who are suffering from insomnia).

Note that NTPTime reads these parameters only once when it starts up, so if you make changes, you need to shutdown NTPTime and restart it before it will use the new settings.

NTPTime Control Panel Servers Page

The list window shows the servers NTPTime will use. The first server in the list is the primary server.
Up: moves the selected server up in the list.
Down: moves the selected server down in the list.
Delete: removes the selected server from the list.
Add: adds the server (or servers) typed in the text field to the end of the list. Separate multiple server names with commas, semicolons, or spaces.
NTPTime is a simple time client, so it does not attempt to average the time from multiple servers in any way. The list simply provides alternate servers to try if the first server doesn't work. The complete retry algorithm is explained in the description for the Retry page.

The server names may be symbolic names or numeric IP addresses.

NTPTime Control Panel Settings Page

Wait for dial up network connection: if checked, NTPTime will check periodically to see if a dial up network connection is active, and set the time only when it finds one.
Exit after setting time once: when NTPTime successfully sets the time, it will exit.
Set time every: set the time periodically according to the specified interval.
Activate sanity check: do not set the time if the adjustment required is greater than specified. (Too big adjustments trigger retry).
Allowed NTPTray interactions: allow ntptray to monitor NTPTime's state and/or send set time requests.
The Exit after setting time once and Allowed NTPTray interactions parameters can be used to set the time only on demand. The set once parameter works best for Windows 95/98/ME where you can just run NTPTime whenever you want to set the time, and the Set Time parameter works best for Windows NT/2000/XP where NTPTime has to run as a service with administrator privileges, but any user can run ntptray. If you set the poll interval to a very large number, then NTPTime will only set the time when someone requests the time be set from ntptray.

NTPTime Control Panel Log Files Page

Enable logging: check this to tell NTPTime to write information about what it is doing to daily log files.
Log file directory: specify the directory where the log files will be written.
Automatically remove old log files: check this to have NTPTime automatically remove the oldest log files when writing new files.
NTPTime tries to be as unobtrusive as possible. When running, it never shows any windows or pops up any messages. The only way you can ever see any feedback about what it is doing is to enable logging and examine the log files it produces.

The log file names are of the form YYMMDD.ntp (where YYMMDD are replaced with the year, month, and day). They are simple text files with moderately cryptic gibberish written to them as NTPTime does its thing. (Note: This is not a Y2K bug. This is just a way to generate unique names).

All the timestamps in the files, and the file names themselves are generated using UTC time, with a new log file generated each time a new day shows up in UTC time.

NTPTime Control Panel Retry Page

Exit after too many errors: check this to set the number of errors which will make NTPTime exit (otherwise it will keep trying forever).
Min time between retries: always wait at least this long between retry attempts.
Max time between retries: never wait any longer than this before doing another retry.
Compute next retry interval: the Add, Multiply, and Divide parameters are used to compute the new retry time from the last retry time R. The formula is R = (((R + Add) * Multiply) / Divide)
Any kind of an error will trigger a retry attempt (unable to look up server name, no response from server, time adjustment too big, etc). NTPTime will try each server in the list once, and if none of them works, it will compute a new retry time according to the above algorithm. The min time is used for the initial retry time, and if the algorithm comes up with a number less that min or greater than max, it will use the min or max time.

When NTPTime successfully sets the time from some server, it resets the server back to the primary server, and the retry time back to the min time, so it will always start in the same state.

NTPTime Control Panel Advanced Page

Startup Delay: wait this long when starting up before attempting to set the time.
Dial up delay: wait this long after a dial up networking connection is made before attempting to set the time.
Set once delay: wait this long after successfully setting the time before shutting down (if the Exit after setting time once option is selected on the Settings page).
Use nonstandard NTP protocol version: set this to change the protocol version number in the time request packets NTPTime sends out.
Use nonstandard NTP port number: set this to request time from a different port number on the server.
The startup and set once delay times are mainly useful when running NTPTime as a service on NT/2000/XP. The service manager gets upset if a service stops too soon after it was just started. These parameters allow you to placate the service manager while still using Exit after setting time once.

The dial up delay might be useful if your system is usually downloading your home page immediately following a dial up connection. You can induce NTPTime to wait a bit for things to quiet down before setting the time. On the other hand, if you are just dialing up, checking mail, then disconnecting, you wouldn't want it to wait too long.

The protocol version and port number settings are mainly for testing. Possibly the protocol version setting could get NTPTime to talk to some older server that doesn't recognize version 3 requests, but I'm not sure if there might be other differences that NTPTime won't handle right. Use at your own risk.

NTPTime Control Panel Obscure Page

Listen for NTP replies on specific port: Normally NTPTime lets Windows pick a random UDP port number it will use to listen for replies from the NTP server. Select this option to pick a specific port number to listen on.
Disable detailed packet content error checks: As of NTPTime version 4.2, the reply packets from the NTP server are checked to see that the server is running at a valid stratum and believes itself to be synchronized. Select this option to disable those checks.
Listening for replies on a specific port may be of use if you are behind a firewall that normally blocks all incoming ports. If your administrator can allow UDP packets for a specific port through the firewall, you can use this setting to convince NTPTime to listen on that allowed port number and set time from a server outside the firewall.

Disabling the errors checks might be useful if you are talking to a server that really isn't properly synced, but is still useful for getting all your computers to agree on the same time (even if it is the wrong time). You almost certainly want to enable the sanity check on the Settings Page if you disable these checks.

Registry Entries

NTPTime uses the registry key HKEY_LOCAL_MACHINE\SOFTWARE\ntcli\NTPTime\4.3 to store the following values:
Value Format Description
NTPServerName string This is the list of server names. The names may be separated with semicolons, commas, or spaces.
LogDirectory string This is the path to the log file directory. This value may be either a REG_EXPAND_SZ or a REG_SZ.
WriteLogEntries dword If this entry is zero, NTPTime will not attempt to write log files, otherwise log files will be generated.
LogFileCount dword If this entry is zero, NTPTime will generate unlimited numbers of log files, otherwise it represents the maximum number of log files to write before old files are automatically removed.
WaitForRAS dword If zero, do not check for dial up networking connections before attempting to set the time, otherwise check for DUN connections periodically and only set the time when a dial up connection is active.
RASPollMilliseconds dword If WaitForRAS is true, check to see if a dial up connection exists every time this many milliseconds elapses.
NTPPollMilliseconds dword If RunOnce is false, try to set the time each time this many milliseconds elapses (but if WaitForRAS is true, may also have to wait for a dial up connection once that time comes around).
RunOnce dword If non-zero, NTPTime will exit the first time it manages to set the time. If zero, NTPTime will continue to run and try to set the time every NTPPollMilliseconds.
MaxAdjustSeconds dword If this is zero, NTPTime will be willing to apply any size time adjustment. If this is non-zero, then any time adjustment greater than this will be considered an error.
RetryMaxCount dword If zero, NTPTime will continue to run, no matter how many errors it gets without managing to set the time. If non-zero, that many errors in a row will cause it to exit.
StartupDelayMilliseconds dword When first starting, NTPTime will delay this many milliseconds before it attempts to set the time.
RetryMinMilliseconds dword This is the initial retry interval. NTPTime will always wait at least this long between retry attempts when there are errors.
RetryMaxMilliseconds dword This is the max time NTPTime will ever wait before attempting a retry when there have been errors.
RetryAdd dword This value is added to the current retry interval as part of the computation of the new retry interval.
RetryMult dword The above result is then multiplied by this factor.
RetryDiv dword And that result is then divided by this factor to generate the new retry interval.
NtpProtocolVersion dword This is the version number NTPTime puts in the time request packet it sends the server. The default value is 3.
AllowPoke dword If this is non-zero, then NTPTime will wake up and attempt to set the time when the ntptray.exe program requests that the time be set now (regardless of what ntptime might be waiting on). If it is zero, then ntptray.exe cannot request the time be set.
AllowMonitor dword If this is non-zero, then NTPTime will create a handful of events which it sets in various states. These events can be monitored by ntptray.exe to display status information. If this parameter is zero, ntptray will always think that ntptime is not running.
RasDelayMilliseconds dword If WaitForRAS is true, this is the number of milliseconds NTPTime will wait after it detects a dial up connection and before it attempts to set the time.
ShutdownDelayMilliseconds dword If RunOnce is true, this is the number of milliseconds NTPTime will wait before shutting down after it successfully set the time.
NTPServerPort dword This is the port number NTPTime will attempt to connect to on the time server. The default value is 123.
NtpReplyPort dword This is the port number NTPTime will use to listen for replies from the server. The default value of 0 means use a random port number.
DisablePacketErrorChecks dword If this is non-zero, then the validity checks NTPTime does on the contents of the incoming replies are suppressed. The default value is 0 (enable error checks).

A sample registry file, ntpreg.reg, is included in ntp43bin.zip and you can edit the contents, then double click on the file name to enter the values in the registry without using the control panel or the registry editor.

The ntcli part of the registry key above is where Microsoft recommends putting your company name. I'm not a company, but I do have a bunch of Windows NT command line interface tools I wrote, so I generally use ntcli in that subkey (I figured you might die of curiosity if I didn't explain that :-).

You can also look at and modify these entries using the Windows registry editor program.

NTPTray taskbar app

If you want to monitor and control NTPTime from your taskbar, you can place a shortcut to ntptray.exe in your Startup folder, and run the NTPTray taskbar application whenever you start windows.

Note that running ntptray.exe is completely optional. NTPTime will keep time with or without it. If your system tray already has 4,721 icons cluttering it up and you prefer not to be bothered, then just don't run it.

NTPTray taskbar icons

By default, NTPTray runs as a taskbar icon application. It shows different icons based on the current state of NTPTime:

is displayed when NTPTime is initializing. If you have a direct network connection, you may never see this, but if NTPTime is waiting for the first dial-up network connection, this will be the state it is in.
is displayed once NTPTime successfully sets the time.
is displayed when NTPTime had some kind of problem setting the time (the server didn't respond, the time information it got from the server was bad, etc). You can look in the log file to see the specific problem.
is displayed when NTPTime is not running. This will also be the state if NTPTime is configured to not allow NTPTray to monitor the state changes. While in this state, NTPTray checks every few seconds (interval configurable in options) to see if NTPTime has started.

A left button click on the icon will request NTPTime to set the time right away.

A right click will bring up the menu.

NTPTray popup menu

Right click on the tray icon to bring up the menu.

Synchronize Now Is the same as left click. It asks NTPTime to set the time right away.
Log Files... pops up a dialog to use for opening a log file. Selecting a file will run notepad (or whatever other application you choose in the options) to view the log file.
Control Panel... pops up the NTPTime control panel. If you change NTPTime settings, the start and stop menu items are handy for restarting NTPTime so it will use the new settings.
Options... pops up the NTPTray options dialog box.
About... pops up the NTPTray about dialog box.
Start NTPTime on Windows NT/2000/XP, this asks the service control manager to start the NTPTime service (if you don't have administrator privileges, this probably won't work). On Windows 95/98/ME it simply attempts to run NTPTime as a normal application (if it can't find it in your search path, this won't work).
Stop NTPTime much like the start menu, this behaves differently on different versions of windows, either asking the service manager to stop the service, or sending a WM_CLOSE message to the top level window named NTPTime.
Exit Tray Application make NTPTray exit.

NTPTray Options dialog

Choose Options... from the menu to bring up the options dialog.

If you really like being annoyed, you can ask NTPTray to popup a message box when it sees the state change. You can pick which new states should popup the message here.

To be slightly less annoying, it won't popup the message if the state change was caused by something you just told it to do (such as clicking Stop NTPTime in the menu).

When NTPTime isn't running, NTPTray checks every few seconds to see if the events have been created and NTPTime is up again. You can control the frequency of those checks here.
When you view log files from the menu, it starts a separate program, passing it the name of the logfile you selected. You can choose a program other than notepad.exe here.
When you click on OK, the options take effect and are also copied to your local registry settings where they will be remembered and reloaded the next time you run ntptray.exe.

NTPTray About dialog

Choose About... in the menu to bring up the about dialog.

The about dialog looks like this:

For extra fun, clicking on the icon or the url at the bottom will take you to the NTPTime home page.

NTPTray command line options

You can run ntptray.exe with various command line options to change its behavior or to pre-set the values from the options dialog.

-help Pop up a window with a summary of these options.
-poke Ask NTPTime to set time now. This option replaces the ntpoke.exe program (ntptray.exe simply exits after making this request).
These options set the various popup message requests from the options dialog.
-pollseconds=int This options sets the polling interval from the options dialog.
-logviewer=progname This option sets the name of the program used to view log files.

NTPTray registry entries

NTPTray uses the (per user) registry key HKEY_CURRENT_USER\Software\ntcli\NTPTray\CurrentVersion to store the options dialog values:

Value Format Description
PopShut dword Non-zero means popup a message when NTPTime shuts down.
PopWarn dword Non-zero means popup a message when NTPTime has a problem setting the time.
PopInit dword Non-zero means popup a message when NTPTime starts initializing.
PopOk dword Non-zero means popup a message when NTPTime sets the time successfully.
PollSeconds dword The number of seconds to wait between checks to see if NTPTime is back up when NTPTime is down.
LogViewer string The name of the program used to view log files.

Year 2000

Now that the Y2K hysteria has diminished, I don't get too many questions about it anymore, but for the record, here is the Y2K lowdown:

The NTP protocol has nothing in it that makes 2000 special, and the time is set by calling the SetSystemTime() service of Windows, so the only way NTPTime could have year 2000 problems is if Windows has year 2000 problems with that service, and you'd have to ask Microsoft about that. If you are really interested, you can find a near infinite amount of Microsoft Y2K information at: http://www.microsoft.com/y2k/default.htm (or there was at one time, Microsoft seems to have removed this link).

On the other hand, sometime in the year 2036 the NTP timestamp will rollover, and NTPTime will stop working. At that time the code in ntp-long-fixed.cpp which uses the JAN_1_1900 macro will have to be fixed to use a different base time (I don't actually know the correct value, but I could probably figure it out from the various NTP rfc documents, but since I have 30 years or so, it didn't seem critical).

A sufficiently fanatical Y2K auditor might notice that the log file names created by NTPTime have a 2 digit year as part of the name. This is just a way to make unique names, they don't mean anything else and the names aren't used for any processing of any kind.

Installing NTPTime

NTPTime can be installed many different ways, but however it is installed and used, it will need to know a name or IP address of a time server, so the first step is to find a time server you can use.

You should go through a two step process to find the best server to use. First contact your ISP or the administrators of any corporate network you may be attached to and find out if they are already running an NTP server. If they are, then that's the one you'll want to use, because it is sure to be closer to your machine than the internet at large.

Many internet router boxes already have the ability to act as NTP servers - your network admins may just be able to activate this feature in their router if they haven't already. In my case, the Adelphia gateway that my cablemodem talks to happens to be willing to talk NTP, so I can point at it. If you have cable or DSL, you might be able to do the same thing.

If there is no local NTP server available to use, then you'll have to consult the NTP Home Page for pointers to publicly available NTP servers. There is no reason, given the accuracy of this program and PC clocks in general to talk to the most accurate "stratum 1" servers. Use one of the "stratum 2" or below servers. Pick one which has low ping times or which tracert shows has a small number of hops (or both). Or just pick one at random (if probably won't matter much). Be sure and read the notes about the server you pick and obey any restrictions about requesting permission, etc. Also be sure to complain to your ISP if they don't run an NTP server as NTP is a value add that ISPs should consider providing.

Note: Windows 2000 and XP come with their own time setting service. You might be able to use the same time server. Check the registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers to see if any servers are listed. Also, if the Windows Time service is enabled on your machine, you might want to disable it since there is not much point in running two different time setting services on the same machine.

Next, you might as well install the control panel and use it to set the registry entries NTPTime will need to operate.

Typically, you will want this to show up in the system control panel so you can double click it just like any other control panel app. To do this, find out where your version of windows stashes its current crop of control panel apps by searching the system drive for files named *.cpl. On most Windows 95/98/ME systems this will be C:\WINDOWS\SYSTEM. On most Windows NT/2000/XP systems this will be C:\WINNT\SYSTEM32 or C:\WINDOWS\SYSTEM32. Copy the ntptime.cpl file to the same directory, and it should automatically show up in the control panel as an icon that looks just like this:


On Windows XP, the control panel has a new Category layout. The NTPTime control panel will only be visible if you switch to the Classic View of the control panel. If you would like to get the NTPTime control panel wedged into the Category view of the control panel, then you can do it with some registry magic. Look in the registry key with the amazing name of:

               Control Panel\
                  Extended Properties\
                     {305CA226-D286-468e-B848-2B2E8E697B74} 2

Now create a DWORD value under that key with the name:


and give it the value 6 (which is the category code for date and time).

That value name should be the full path name to where you copied the ntptime.cpl file. The name shown is the standard location for control panel apps on XP (you can really use the %SystemRoot% string as part of the name, you don't need to expand the environment variable yourself).

The ntpxpcat.reg file is a registry file included with the ntp43bin.zip file. You can double click on it to automatically install the registry key described above.

If that's all too complicated, you can actually leave the ntptime.cpl file anywhere and run control.exe passing it the ntptime.cpl file as an argument, and it will run the control panel.

In any case, once you get the control panel installed, you will want to run it to tell NTPTime which server to use and set the parameters which tell it just how to operate.

On Windows NT/2000/XP you probably want to install NTPTime as a service. You must be running as an administrator to do this. First, copy the ntptime.exe program to where you want it to live (the same directory as the ntptime.cpl program is always a good place), then open a command window, cd to that directory, and run the command:

.\ntptime --install

If that worked, since you are already in a command window, you can now start the service by running the command:


and the service should start up, set the time, generate log files, and all that jazz. (You can check the log files to see if it is really working). If you like graphical interfaces, you can also start the service from the Services control panel.

Once installed as a service, NTPTime should automatically start running each time you boot the system.

If you don't want to run NTPTime as a service, you can also run it the same way 95/98/ME run it (as a normal windows program) if you give it the --w95 option. So you can do most things the next section describes as long as you always add --w95 to the command line (but it will only work if an administrator runs it).

On Windows 95/98/ME there is no service manager, so NTPTime runs as a regular windows program, but it doesn't display a window. It always runs as a hidden window that will only show up in the task list, but not on the screen or the taskbar.

The simplest way to install NTPTime is to make a shortcut to it in the Startup folder. Each time you login, NTPTime will automatically start. If you want to run the ntptray.exe program, you can also make a shortcut to it in the Startup folder.

If you have a multi-user system, and you want NTPTime to run even if no one is logged in, you can also make a value under the registry key:


This will start NTPTime when the machine boots, without waiting for anyone to login.

Of course, if you don't want NTPTime cluttering your system all the time, you can simply make a start menu entry for it so you can easily run it whenever you want to set the time. If you also choose the Exit after setting time once option on the control panel Settings Page, then NTPTime will merely set the time when you run it, and exit right away.

UnInstalling NTPTime

The Installing NTPTime section covers several different ways you might want to install and use NTPTime. This uninstall section simply describes the most obvious things to look for. The basic idea is to read the install section backward, and if it says run the --install option, use --uninstall, if it says start a service, stop it instead, etc. If you don't know how the old version was installed, your best bet is just to check everything mentioned in the installation section.

On Windows NT/2000/XP, the first thing you need to do is make sure the NTPTime service is stopped. You can either bring up the services dialog (located either in the control panel or under administrative tools from the control panel) and look for NTPTime, stopping it if it is running, or you can start a command window and issue the command:


Of course, neither of these things will work if aren't running as administrator.

Once you have stopped the service, cd to the directory where the current version of ntptime.exe is installed, and issue the command:

.\ntptime --uninstall

On Windows 95/98/ME, you don't need to uninstall a service, but you should make sure the old ntptime program isn't running. Bring up the task manager by pressing Ctrl-Alt-Del on the keyboard, and if NTPTime appears, click on it, then push the "End Task" button.

If you have startup folder shortcut pointing to ntptime.exe, you should delete it before deleting the program. If you setup your system to use the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices registry key, to startup ntptime (rather than the startup folder), then remove the registry key before deleting the program.

At this point, whichever operating system you are using, you should be able to delete the old ntptime.exe program, as well as the ntptime.cpl control panel, and your system will be free of NTPTime influences.

If you are uninstalling an old version so you can install a new version, this is a good time to install the new version (so the new control panel will be able to copy your old registry settings before you remove them).

Once you have installed the new version, or if you just want to get rid of the old version completely, look for registry entries under HKEY_LOCAL_MACHINE\Software\ntcli\NTPTime and delete all the old version registry entries.

If you want to utterly eradicate NTPTime, you can delete the NTPTime subtree, and if that leaves nothing under ntcli, you can delete it as well.

If you had a copy of the ntptime.html file on your system, you might want to find and delete it, and if you were logging the results of NTPTime, you might want to delete all the log files and the log directory as well.

If you were using the NTPTray program, you should also check to see if you have a Startup folder shortcut to it, and delete the shortcut and if you ever configured any NTPTray options, you will want to delete the HKEY_CURRENT_USER\Software\ntcli\NTPTray\CurrentVersion registry key.

Download NTPTime

There are three .zip files available for download:
  • ntp43bin.zip contains the binaries you need to install NTPTime on your computer. This includes the ntptime.exe program, the ntptime.cpl control panel, and the ntptray.exe utility, and well as other scripts, registry files, etc.
  • ntp43doc.zip contains this html file along with the images it points to. You can download this if you want a convenient way to have a local copy of the documentation on your system.
  • ntp43src.zip contains the complete source code for the programs and control files. You can build everything you need from this and forget about ntp43bin.zip if you don't trust pre-built binaries.

Build NTPTime

The ntp43src.zip file containing the source code must be unpacked with a zip that supports long file names and unpacks directories correctly. The file contains 4 directories:

  • ntptime contains the source for the ntptime.exe program.
  • ntpcpl contains the source for the ntptime.cpl control panel applet.
  • ntptray contains the source for the ntptray.exe program.
  • ntpoke contains the source for the (obsolete) ntpoke.exe program.
  • ntpmisc contains scripts, registry files, etc. (nothing needs building in this directory, but these files are shipped with the binary zip file, so they are included here in case you want to build everything you need from the source).

I build these on Windows XP with Visual C++ 6.0 and the Microsoft Platform SDK from around January 2002 (sometime after that, Microsoft started forcing you to install all of .NET, and I'm avoiding that, so I'll probably be on VC++ 6.0 forever). I don't make any promises about other versions of the compiler or older libraries, and if you want to use Borland or GNU compilers, you are completely on your own.

If you don't have VC++ environment variables installed, you may need to run the VCVARS32.BAT file that Visual C++ installs in its bin directory before you try to do the builds.

Each of the ntptime, ntpcpl, and ntptray directories contains a Makefile. You can build each of them by cd'ing to the directory and typing nmake.

If you are addicted to the Visual Studio environment, you can set these up to build with it fairly simply by just including all the source files in each directory in a new project. Make sure you use Win32 Application as the kind of project for ntptime and ntptray, and Win32 Dynamic-Link Library as the kind of project for ntpcpl.

For ntpcpl you also need to tell the project to link with the ntptime-cpl.def file to correctly define the magic control panel app entry point.

You should also consult the link lines in each Makefile to see what libraries need to be included (the standard set of libraries VC++ provides by default won't always work).


Because NTPTime runs as a service that starts when the system boots, network drives and connections may not be properly setup when it starts. It probably isn't a good idea to try to install NTPTime to run from a network drive or point the log directory to a network drive.

I originally developed this under Windows NT 4.0 and I now run this on my Windows XP system at home, and it hasn't caused any problems (since the one when I was running NT where it would hang the service control manager :-). But remember, this is free software, it has only as much support as I feel like providing. User beware. On the other hand if you really want something fixed, the source is available too, so you can always fix it yourself. I have also tested it on Windows 95 and Windows 98 and it seems to work fine there as well.

I have never run Windows ME or Windows 2000 (other than brief tests), but I don't know of any reason it shouldn't work with them. Versions of NT prior to 4.0 are a bigger question. I have my doubts about it working there.

Yes, there is a program named ntptime out there already, but it appears to be something to read magical time parameters from some special precision timekeeping kernels. I didn't think it could be generally confused with this, and I like the way Windows NT and the NTP protocol both lend themselves to the NTPTime name :-).

To set the time, NTPTime needs to talk to an NTP server using the TCP/IP UDP protocol. Many firewalls won't relay UDP packets, so if you are behind such a firewall, your best bet is to convince the powers that be to run an NTP server on the firewall, then you can talk to that. As of NTPTime version 4.2 there is also the obscure setting to tell NTPTime to listen for replies on a specific port. This may be useful to get through some firewalls.

NTPTime uses the win32 SetSystemTime() call to set the time. This interface wants the time expressed in UTC (universal time coordinated, or just a fancy name for GMT). This means that if you don't have your machine configured properly to use the right timezone and daylight time settings, the time won't appear to be correct, even if NTPTime is functioning perfectly. You can use the date and time control from the control panel to setup the timezone information. On a related note, the log files also long entries with UTC timestamps, and the new log file generated each day uses UTC to determine when a new day begins.

Some governments seem to be constantly fiddling with the daylight savings time standards for their country. As a result, windows may not be able to set the correct timezone for your computer. Microsoft has a utility program available on their web site for editing timezone and daylight time parameters. You can look for http://www.microsoft.com/windows/download/tze.exe (but that link seems to have disappeared), or you might simply go to http://www.microsoft.com/ and use their search feature to look for tze.exe or the phrase "time zone editor", to find perhaps new and improved timezone editing programs. Sometimes a time zone editor is part of "power toys" or "kernel toys" packages, so you might search for them as well.

If you are running this, and also running some kind of high overhead game that hogs every resource it can get, I make no promises about any interference this might cause with games. Best bet is not to run it at the same time you are playing a game.

On Windows NT, the --install option which installs NTPTime as a service also makes NTPTime dependant on the RasMan service, if that service is already installed at the time you install NTPTime. This dependency is required for the service to start correctly at boot time if it is going to be polling for a dial-up connection. If you modify your NT configuration and install or uninstall the RAS services, you probably want to uninstall and reinstall NTPTime as well. With version 4.0, you can also use the --noras command line option to prevent any RAS dependency from being created.

On Windows 95 and 98, NTPTime runs as a completely hidden windows program. If you don't see anything happen when you start it up, that's perfectly normal. The only sign that it is running will be the log file entries it creates (if you configured the registry to write log files), and the entry that will show up for it in the task list you get when you type Ctrl-Alt-Delete. You can use the task list to select NTPTime and do an "End Task" if you need to shut it down (which is slightly less drastic than rebooting the computer to shut it down :-).


Some useful resources for NTP information are:

  • NTP Home Page This is the source of all knowledge about the NTP protocol, available programs, etc. It has pointers to everything you might want to know about NTP, including the NTP FAQ.

  • rfc 1305 NTP protocol This is the internet standard document which defines the NTP protocol.

  • rfc 2030 SNTP spec This is an internet standard document clarifying issues involved in using NTP for simple time setting clients such as NTPTime.

  • rfc 1769 SNTP spec This is the original SNTP spec which 2030 clarifies.

  • comp.protocols.time.ntp is a usenet news group where you will find NTP discussions.

  • Tom's Home Page This is the obligatory pointer to the author's home page.


You can reach me with feedback at

Bug reports should mention stuff like which operating system you are running on, which version of NTPTime you are using (you might want to check this web page to see if there is a newer version which might already fix your problem before reporting it). If the bug is unexpected termination of the program, then including the log file showing any messages it might have recorded will be a help (if you have logging turned off, I doubt I'll be able to guess what went wrong from zero data, try turning logging on and wait and see if it happens again).

Enhancement requests are also welcome, most especially ones which come with source code patches to implement the enhancement (which is one of the reasons I make the source available).

Just remember, I do this for learning and fun, not to make a profit, so don't expect lightning quick response (for example: it was about 2 years between 3.0 and 4.0). I only have a limited amount of free time to kill fooling with this program (but at least I can keep track of it very accurately now).

Any fury or flames about this program should be directed at the fool who decided to run an unsupported free program on his or her computer, not at me :-).

Deep Thoughts

Why does the world need another NTP client? It doesn't really, I just wanted to learn about writing Windows NT services, and I wanted the service I wrote to be something "real" rather than one of the dummy samples you often see in Microsoft's documentation. I also thought NTP was interesting, so I chose that as my project.

In addition to learning about services, I also took this opportunity to use exceptions and some of the other new C++ features. That turned out to be fun as well, and I learned a lot about how to make using exceptions a safe thing to do when you also need to worry about releasing critical sections, freeing up sockets, etc.

So, if yet another NTP client offends you, I apologize, but I found it a useful project, and as long as I had it, it seemed a shame not to clean it up a bit and make it available for anyone else who wants it. Once I suckered myself into making the initial release, NTPTime sort of took on a life of its own, so I'm now up to version 4.3.

Finally, the real subversive motive behind this program is using the free software I write as bait to lure unsuspecting people to my home page, where they can read about the political ideas that will revolutionize governing for generations to come! They will then write their congresscritters about it. The congresscritters will steal the ideas so they can take the credit, and pretty soon the whole country will be running with my ideas.

Funny thing, this part doesn't seem to have happened yet :-).


The initial release of NTPTime was version 2.1. This was a console program primarily useful as an NT service and not well suited to running on 95/98/ME.

Version 2.2 was an internal version I never fully released. It didn't do much other than some improved (or different, anyway) error logging and making the NT service dependencies be a little smarter about RAS.

Version 2.3 was a bugfix an minor enhancement release. It no longer required RAS to be installed on your machine in order to run NTPTime. It loads the rasapi32 library when it needs to reference it to decide if a dial-up connection is active. If you don't ask it to wait for a connection, it should never need RAS. When installing the service, it will only make itself depend on RAS if RAS is installed (if you install or uninstall RAS, you might want to uninstall and reinstall NTPTime as well). Version 2.3 also changed from a console program to a windows program. Windows programs work better under Windows 95 or 98 (if you leave it running, it won't interfere with a shutdown). This also means that if you run it with options like --help, it pops up a message box rather than trying to print to the console. I also allowed an IP address string as well as a DNS name for the time server.

Version 3.0 was mainly a bug fix release, and the control panel first appeared shortly after 3.0.

  • The major enhancement added was the LogFileCount registry value which may now be used to automatically clean up old log files. This seemed worth a new major version number, hence 3.0.

  • Over time I got several reports from various places about SetSystemTime() complaining about bad data. I could never reproduce this, and was never sure if it was due to bad NTP packets, or something stupid I did. Finally thanks to Mike Castle I was able to nail this bug (naturally it was stupidity on my part, not bad NTP packets :-). The problem was the way I was converting the NTP timestamps to SYSTEMTIME. About 1 out of every 2000 times, I'd wind up generating a millisecond value of 1000 due to the way the rounding code was written, and SetSystemTime() didn't like that because I should have added that into seconds, not given it as milliseconds...

  • Ari Reen tracked down a leak from OpenProcessToken where I was failing to close the token, so every time NTPTime would set the time, it would leak another process token. This leak is now plugged. (I have had other reports of long running NTPTime processes growing to consume lots of memory, I don't know if this is the only leak, but it should certainly help).

  • Lee Ott helped me find a problem I still classify as a Microsoft bug, but Microsoft doesn't, so I have now fixed the call to CreateService() which is used by the --install option so that it puts quotes around the path name of the program if it has spaces in it (previously if you tried to install it somewhere under a directory with a silly name like "Program Files", the service manager would barf and leave log entries saying something like "Event ID 7000: %1 Not A Valid Windows NT Application").

  • R. Jong-A-Lock suggested that allowing a REG_EXPAND_SZ entry for the LogDirectory registry entry could add some flexibility, which seemed reasonable, so I have added that enhancement.

  • Lyman Fretwell pointed out that the round trip time calculations I blindly copied from RFC 1769 and RFC 2030 are both wrong (because the RFCs are wrong), so I have corrected the calculation to use the algorithm from the official master spec RFC 1305. This was not a real critical problem, because all it does with the round trip time is display it in the log, but if you notice a change in the delay times, this probably explains it.

  • Nigel Charlton wanted to put an unattended install setup wrapper around NTPTime, and the message boxes it pops up were messing that plan up, so I now allow you to stick a 'q' (for quiet) on the end of the --install or the --uninstall option, and if everything works right, it won't popup any message box.

The control panel was actually a post version 3.0 addition, but since it didn't change ntptime itself, all I did was update this document and add the additional links to the control panel source and executable.

That's about it for the major fixes. Other minor things included document updates and the addition of a sample .reg file for people to use instead of the registry editor if they feel more comfortable with that.

Version 4.0 has a large backlog of enhancements and bugfixes folded into it.

  • The most requested enhancement has been multiple server support, so in 4.0 you can specify several comma, space, or semicolon separated names in the NTPServerName registry value, and if an error occurs, it will cycle through the servers until it manages to set the time (at which point it will reset everything back to the first server name for its next time setting attempt).

  • For multiple servers to work properly, NTPTime had to be modified to retry on errors rather than shutdown. There are now several new registry entries that control how NTPTime acts when it retries.

    RetryMinMilliseconds is the initial number of milliseconds to wait between retry attempts. Once it has tried each server, it can adjust the retry period to wait longer.

    RetryAdd, RetryMult, and RetryDiv are used to compute the next retry wait time as follows: new_wait = ((old_wait + RetryAdd) * RetryMult) / RetryDiv.

    RetryMaxMilliseconds is the longest time it will ever wait between retries (regardless of the other retry parameters).

    RetryMaxCount is the max number of times it will retry. If it cannot successfully set the time in this many tries, it will shutdown the service. If you specify multiple servers, this number needs to be bigger than the number of servers, or there are some servers it will never try.

  • Gijs van Reijendam educated me about the use of port 123 in a NTP client program. NTPTime no longer insists on using port 123 to listen for replies, instead it lets Windows pick a random port number. This means it can run on the same system with another NTP client or an NTP server (though that probably isn't a good idea for other reasons - such as multiple time programs fighting over the right time correction).

  • The most recent log file is now closed when NTPTime isn't writing it. This makes it simpler to see the log content on Windows 95/98/ME (but it would be a bad idea for you to keep the log file open when NTPTime comes around to write on it again, so be careful).

  • The --install option now checks for RAS service being installed but disabled, and doesn't make NTPTime depend on RAS if it is disabled.

    There is also a new --noras command line option. If you use it ahead of --install, it won't make the RAS service dependency even if RAS is enabled.

  • The bug that made NTPTime hang instead of properly shutdown when running on Windows 95/98/ME is fixed. When it says it is shutting down, it really goes away now.

  • NtpProtocolVersion is a new registry value to control which protocol version number NTPTime puts in its time request packets. NOTE: All this does is set the version, I don't know if different version servers are likely to require different algorithms to process the response, but if they are, then this probably won't do any good. It is mainly just something for people to try if they are wanting to talk to some rickety ancient server that won't recognize version 3 requests.

  • The --install option now installs the descriptive text that shows up in the service manager for Windows 2000 and XP.

  • The new ntpoke.exe program ships with NTPTime. When you run this program it "pokes" the NTPTime service and makes it attempt to set the time right away (even if you told it to wait for a RAS connection and there isn't one active). NOTE: I suppose malicious users could attempt to clog the network with NTP requests by running ntpoke over and over in a loop, so there is also a registry value AllowPoke which can be set to zero to make NTPTime utterly ignore the ntpoke program. This is mostly useful on Windows NT/2000/XP where NTPTime runs as a service, but any user can run the ntpoke program.

  • StartupDelayMilliseconds, and RasDelayMilliseconds are new registry values to make NTPTime wait a bit before trying to set the time when it starts or when it sees a new dial-up connection. ShutdownDelayMilliseconds is a new registry value to make NTPTime wait before shutting down when RunOnce is true (this is mostly useful to prevent the service manager from becoming upset that the service shutdown right after it was started).

  • The links to RFC documents now use the http://www.ietf.org/ server to point at the RFCs (which appears to be where they live these days).

  • Added warning about network drives and NTPTime.

  • The control panel was extensively modified to support all the new registry parameters.

  • This document was extensively rewritten.

  • Instead of separate files, the executable and control panel are now packaged as a single .zip file along with various helpful (or not :-) scripts. This should eliminate the problem people frequently had with Netscape insisting that .cpl files are text rather than binary. (If anyone can tell me how I can set the mime types on a link in an html document without having any control over the http server, please let me know).

Version 4.1 was rushed out a few days after 4.0 to fix some bugs that cropped up in the Wait for dial up network connection code. Not only could this code never have worked (I don't understand why it ever did :-), but once I got the bug fixed, I found that I needed to build the RAS connection query code with a older WINVER defined for anything other than Windows XP to be happy.

4.1 also fixed some typos in this document and added a section to the appendix on the registry editor and a few other notes and links as long as I was modifying the html file anyway.

Finally, testing ntpoke.exe uncovered some problems where you sometimes had to poke NTPTime more than once. That is now fixed.

Version 4.2 finally showed up a couple of years after 4.1. It adds a new (completely optional) system tray icon application, fixes some bugs, and adds a few other new features.

  • Artur Wieczorek provided some bug fixes for the WrapService class as well as the source for a new NTPTime taskbar icon application (I then went crazy and rewrote it pretty much from scratch, so don't blame Artur for things you don't like about it :-). The new ntptray.exe program has replaced ntpoke.exe (although ntpoke.exe still works). A rather large hunk was added to the manual to document all the new NTPTray features.

  • Jerry D. Farmer provided the code I never got around to writing which will validate the reply packets from the server to make sure the server is in sync, has a valid stratum, and provided a non-zero timestamp.

    I added the new obscure setting to disable most of these sensible checks if you happen to need to talk to a nonsensical server.

  • Ferdi Louw and Peter Heberer both pointed out that you can run control panel apps by passing them as the argument to control.exe, and Ferdi Louw went even farther by providing a new and improved ntpquick.bat file to take advantage of it.

  • Several people have asked about running NTPTime through a firewall. I know very little about all the different kinds of firewalls out there, but apparently some of them can be configured to allow traffic on specific ports. If you are behind such a firewall, there is a new obscure setting to tell NTPTime to listen for replies on a specific port number rather than getting a random port number from the operating system. If you and your firewall administrator can agree on a port, you may be able to get NTPTime to run from behind the firewall.

  • David Nemeth provided the ntp.adm file for use with the group policy editor to allow system administrators to control who can access the NTPTime control panel.

Version 4.3 is primarily a quick bug fix release.

Soon after 4.2 was released, I got reports from several international users that the creation of the ntptray events was failing. I have completely rewritten the code that builds the security attributes for the events to avoid any use of API calls that deal with names of any kind, using lower level functions to get "Everyone", etc. Hopefully this will allow ntptime to create the events no matter what locale it is running in. Christian Bendt was kind enough to test the new code for me and verify that it works on his machine.

Also, soon after 4.2 was released, David Mills pointed out the existence of his proposed rfc with guidelines for simple NTP clients. Since the guidelines seem reasonable, I'm implementing the the most important missing feature: the recognition of "kiss of death" packets which servers use to tell clients to stop bothering them. Many of the other recommendations are very close to what ntptime already does, but since I wanted to get version 4.3 out quickly, I didn't do a complete set of rfc-xxxx changes (that gives me something to do for 4.4, and by then rfc-xxxx may be an approved standard with additional recommedations I need to implement).

While testing the "kiss of death" support, I found a few ways the service could shutdown and fail to notify the ntptray program. I fixed those, so so odd boundary conditions will no longer confuse ntptray.

That's it. Version 4.3 is the most recent version (as of April 30, 2004).


The manual has been filled with references to special bits of Windows and other things that may or may not be familiar to the unknown audience out there, so this appendix tries to cover some of the basic points that might need additional explanation:

Since all the NTPTime files are packed in .zip files, you will need a way to unpack them. Windows XP already has built in support for zip files, so XP users shouldn't need to do anything special. For other windows users, a freeware zip file solution can be found at the Info-ZIP home page. If you like commercial software with a fancy interface, the most widely used commercial zip utility is probably WinZip.

Several places mention opening a command window. Microsoft keeps changing the name and moving the menu entry around for this. In Windows 95 it was called a MS-DOS Prompt, somewhere along the way (I think in Windows 2000) the name changed to Command Prompt and it moved out of the programs menu and into the accessories menu. Here is where to find the menu entry on Windows 95:

Here is what the menu entries look like in Windows XP:

If you look around under programs or accessories you ought to be able to find MS-DOS Prompt or Command Prompt somewhere on your system no matter which version of windows you are running.

On all versions of windows, if you select the start menu "Run..." option, you should be able to type "command" as the name of the program to run and have it popup a command window.

The most convenient way to run programs is to have shortcuts to them in your start menu. You can make new shortcuts by using windows explorer. First right click the start button and choose the Explore option:

That will bring up something a lot like this:

Double clicking on Programs will take you into that folder. Clicking the folder with the up arrow on it on the toolbar will take you back up one level, etc.

Right clicking in the right half of the explorer window will allow you to create new folders or shortcuts, like this:

The folder named StartUp under Programs is special. Any shortcuts in there will be run automatically when you login, so this is a good place to make a shortcut to NTPTime if you want to run it a login:

On Windows NT/2000/XP you need to know how to find the service manager to start and stop NTPTime (for instance, if you change some parameter with the control panel). This hasn't moved around quite as much as the command prompt, but you might have to wander around to a couple of different places to find it.

On Windows NT, the service manager is right in the control panel. On Windows XP, you have to first go through the Administrative Tools icon to see the service manager icon. If you are using the category view in the control panel, you have to look under Performance and Maintenance to find Administrative Tools (are you lost yet?). I'm not sure where it is on Windows 2000, but it is probably in the same general vicinity of one of these.

On Windows 95/98/ME you may also need to start and stop NTPTime. Since it doesn't show on the screen, you need to bring up the task list in order to stop it. Press the Ctrl-Alt-Del keys at the same time, and a window like this will pop up where you can select NTPTime and click on End Task:

The registry is mentioned a lot in this document. It is a magic set of files where Windows stores almost all of its configuration information. There are two programs available for examining and modifying the registry. All versions of Windows have a program named regedit. Windows NT/2000/XP also have regedt32. The difference is that the regedt32 version of the registry editor will let you modify permissions on the registry (so, for example, you could make the HKEY_LOCAL_MACHINE\SOFTWARE\ntcli\NTPTime\4.3 key where NTPTime stores its parameters writable only by administrators if you wanted to make sure ordinary users on your machine didn't modify the NTPTime parameters).

On Windows XP, both these versions of the program appear to be identical.

These programs are not usually in any predefined menus. The simplest way to run them is to click the Start button and select the Run... choice, then type the program name in the dialog box that pops up.

Page last modified Fri Apr 30 19:19:06 2004