WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Synchronize the Time between Workstation and Server

Keywords: 	 synchronize time 

Question:

Is there a way to synchronize the time between a workstation and a server?

I am writing a logon script and I would like to synchronize the workstations's time with a server. I know how to set the workstation's time using IntControl (58, p1, 0, 0, 0), however, I can't seem to find a function to get the time off of a server.

Answer:

Take look at the the Win32 Network Extender functions: w9xRemoteTime and wntRemoteTime


From Windows help:
Displays the time on or synchronizes your computer's 
clock with the shared clock on a Microsoft Windows for 
Workgroups, Windows NT, Windows 95, or NetWare
time server.

NET TIME [\\computer | /WORKGROUP:wgname] [/SET] [/YES]

computer Specifies the name of the computer (time
server) whose time you want to check or
synchronize your computer's clock with.
/WORKGROUP Specifies that you want to use the clock on a 
computer (time server) in another workgroup.
wgname Specifies the name of the workgroup containing
a computer whose clock you want to check or
synchronize your computer's clock with. If
there are multiple time servers in that
workgroup, NET TIME uses the first one it 
finds.

/SET Synchronizes your computer's clock with the
clock on the computer or workgroup you
specify.

/YES Carries out the NET TIME command without
first prompting you to provide information or
confirm actions.
Maybe...
   RunWait("NET.exe","TIME \\server /SET /YES")
If you are running on NT workstation, with restricted privileges (ie: Not local admin) then NET TIME will fail unless your user account has the specific privilege which allows the time to be changed.

Look in the NT resource kit for TIMESERV - this is a time service that is installed on servers and workstations, and basically keeps the two in synchronisation by checking the time every few minutes, or hours, according to your preference. If the workstation drifts more than a second or so off the server time, then it is brought back in line and an entry is written to the event log. TIMSERV also supports dialing out to on-line atomic clocks, etc, to keep the server time spot on.

You don't need any special privileges to use NET TIME, just an account.

If you have Internet access on the server, you could use AtomTime to set the server. Then use NET TIME to set the workstation to the server.

   http://www.atomtime.com
If you can find it, there's also an old freeware version of AtomTime that works fine.

I have seen a free utility that you can run on Windows 95/98 and NT 4.0 and above. It will update the time from a server off of Internet while at the same time acting as a time server for the local net. I got it from http://www.ossystems.co.uk/ and it was called "Time Lord". Sounds like it might do what you need?


Article ID:   W14309
Filename:   Synchronize Tme between Workstation and Server.txt
File Created: 2001:01:09:11:44:14
Last Updated: 2001:01:09:11:44:14