net time & w32tm problem

I have a client/server application in .NET in which communication between the two is time sensitive and requires both machines to be sync'd.

XP dos, and the version of dos on win2k are different.  So some of the commands are different.  

IE:  winxp is w32tm /resync
      win2k is w32tm -s

These are the steps I think I need to do:
1)  set sntp server. This currently works on both machines like this
        net time /setsntp:<machineName>

2) update the time, and if possible set interval at which it will check to make sure the time is in sync.

win2k - currently doing:
           net time stop w32time
           w32tm -s (or -once?) -period 65532 (to sync ever 8 hours)
           net time start w32time

now this works...the first time when I use -once, but not -s.
Both -s and -once will sync the time after the service is started (unless the -s attempt just failed and is using previous settings from my -once attempt).

However,  i set the period to 1440 (to sync every minute) and it doesn't sync every minute.  I've set the time ahead and back (knowing that it handles those 2 scenarios differently... i think if its back it slowly syncs and if its ahead it'll do it immediately).

and with winXP  this command works :
          net time /set /y

however that command does not work on win2k? ? ? ?   i get "System error 5 has occured"

I have done research on this system error 5 and can't seem to figure out what the problem is.
Anyways.. seems like there are a lot of examples on the web.. so please.. DON'T POST LINKS!!  lol.  

I'll save you the trouble to what I've seen and what I've tried....
Who is Participating?

are you supplying a server to sync with in the cmd?


net time \\someServer /set /yes

bswiftlyAuthor Commented:
you mean when I try it in win2k?  

If I supply the computer name as you suggest, I get the System error 5 message as well.

Although as I understand it, after I have set the sntp server, I can just run w32tm -s  and it'll sync to that server.  

i'm assuming that:

net time /set

command just calls the w32tm function? am I right?

Sorry I cant be of more help here but I'm still on an NT domain :(

With nt I supply a server name the the cmd sync the time with that server, reguardless of sntp.

Try the cmd from the cmd line and see if it works.  Just use the server name of your sntp server.

I have to disable the w32tm service in XP clients becuase NT domains, and workstations, do not support it.  However I'm not sure about 2k machines.

In xp you can use the /setsntp to set up your clients to sync with your sntp server.

/SETSNTP[:ntp server list]
                Sets the NTP time servers to be used by this computer.  This
                may be a list of IP addresses or DNS names separated by spaces.
                If multiple timeservers are listed, the list must be surrounded
                by quotes.

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

net help time

for full details...

Might want to run this from the cmd line on an 2k workstaion to see its capabilities.

Sorry missed this:
>>Although as I understand it, after I have set the sntp server, I can just run w32tm -s  and it'll sync to that server.

if it still does not work try syncing with this cmd as a workaround:

net time \\sntp /set /yes

where sntp is the computer name of your sntp server.
bswiftlyAuthor Commented:
that /setsntp command you mentioned was in my original post.  

and yes i've been through the net time ?  list of options and they are different i had mentioned win2k's equivalency of xp's w32tm /resync  is w32tm -s.  net time options are different as well but on win2k i've been using the win2k list and i still get that error.

Thanks for the input though.

I'm wondering why I can't find a lot of helpful documentation with M$
Did you see these?

120944 - Using NET TIME for all Workstations and Servers;EN-US;q120944

How to Configure an Authoritative Time Server in Windows 2000

and for the time service docs:

R U running a 2k domain?

bswiftlyAuthor Commented:
Pretty sure its a 2k domain.  

Haven't seen those links but if you look at the links I posted...there is more information than in the ones at the microsoft site that you posted there..  i'm confused as to why this is happening.

I use this cmd in my startup script on my NT domain:

net time \\mailsvr /set /yes

so each computer on the network gets it time sync'ed with my mail server at every logon.

When user log on their 2000 workstaions it does sync the time.  Some thing to consider if you have control over the domain or access to the admin :)

Good Luck,
bswiftlyAuthor Commented:
well the way I have it working right now is as above, it checks the OS, and then runs a batch file to set up the time server.  

As posted initially, I have it working on both OS's when the service starts (ie on boot up).   But the w32tm -period  parameter doesn't seem to fire.  I set the interval to 1 minute and 3,4,5 minutes go by without updating the time...  I guess this was my main question.   Is my syntax wrong for the -period command.?

not sure...

fire up regedit and look here:


and check the period key.

Used to control how often the time service synchronizes. If a value is given, it must be one of the
special values listed below.

     65531, "DailySpecialSkew" = once every 45 minutes until successful one time, then once every day
     65532, "SpecialSkew" = once every 45 minutes until successful three times, then once every eight hours (three times per day) [default]
     65533, "Weekly" = once every week (seven days)
     65534, "Tridaily" = once every three days
     65535, "BiDaily" = once every two days
     0 = once per day
     freq = freq times per day. If you choose to add a value other than any of those specified above, you must use this option.

Dont modify these settings just check to see if it is set.
If you look at the documentation the -s switch forces the computer (or the local computer if none is specified) to resynchronize, then *exits*.

Also found this at the end of the win32time docs:

I know my computer's time is incorrect. Why hasn't it synchronized yet?
A clock on a computer does not adjust itself immediately. A computer synchronizes with the time server at system startup and then every 45 minutes until it has successfully synchronized three times. When the clocks are correctly synchronized, they sync again after eight hours, and every eight hours after that. (For a description of how to manually change this setting, see "W32Time Registry Entries" earlier in this article.)

and this is true for the time you have selected:

 65532, "SpecialSkew" = once every 45 minutes until successful three times, then once every eight hours (three times per day) [default]

bswiftlyAuthor Commented:
ah.. i haven't read that freq. thing before... maybe just missed it..  i thought i could just say -period 1440 for every minute.  

so do i go w32tm -s -period freq 1440 ?   or whats the syntax there then ?

just w32tm -s -freq 1440?

I'll test and let you know if you don't first
You can only use these numbers:

0 = once per day
65535 = once every two days
65534 = once every three days
65533 = once every week (seven days)
65532 = once every 45 minutes until you get three good syncs, then once every eight hours (three/day)
65531 = once every 45 minutes until you get one good sync, then once every day

If you use anything else it is times/day.  so 1440 would be once a minute.  I think freq is just the number you pass to it.  try running the cmd with the -v switch so you can see whats going on.

w32tm -s -period 1440 -v

bswiftlyAuthor Commented:
you have to put in freq.  

if you use one of the numbers listed, you don't have to...

w32tm -s -period 65532     //no freq needed

w32tm -s -period freq 1440  //have to list freq if you are going to use a custom #.  that works.

bswiftlyAuthor Commented:
thanks for your help.. i sort of worked around it myself but i'll give you the points for the effort.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.