• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

System time in LAN

Hi.

Is it possible to change the time, at the taskbar, on all computers in LAN simultaneously?

Thanks in advance.
0
CodedK
Asked:
CodedK
  • 7
  • 5
  • 2
2 Solutions
 
geobulCommented:
Hi,

Set one computer as a time server. Set all computers in the LAN to use that computer as time server ('NET TIME' command). Now you can change the time on that time server only and all other computers will synchronize the change instantly.

Regards, Geo
0
 
CodedKAuthor Commented:
Hi Geobul and thanks.

You said (Set all computers in the LAN to use that computer as time server, mine as a time server)...

How can i do this within my application?
0
 
BarthaxCommented:
Are you looking to push the time out programmatially?  If so, I would advise simply wrapping the "net time" options that is built in to each version of Windows.  Here's the URL for the XP version: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_time.mspx

As far as I know there is no 'broadcast' facility (tool or protocol) to push the time to all machines in a single run.  As a result, the problem you face then is simply to discover what machines are on your network in order to have a list of IP addresses to push the time out to.

Alternatively, if you are looking at setting the time locally for a particular machine, you could still use the "net time" command or you could build into your application support for the Network Time Protocol (NTP): http://www.ntp.org/ and retrieve the time from a source of your choosing (providing the source serves NTP).  There are ample NTP clients & servers already available on the 'net for free, so this would be simply duplicating what is already widely available (see the NTP site given).
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
CodedKAuthor Commented:
Hi Barthax..

I have all the IP addresses.
Can u give me some code? (...wrapping the net time)

---->
As far as I know there is no 'broadcast' facility (tool or protocol) to push the time to all machines in a single run...
 example:
http://www.sharewareconnection.com/nettime-server-client.htm

But this application synchronize the lan time with a server.
I dont want that.... i allready have the right time and i want to push it in all the pcs.

Thanks
0
 
BarthaxCommented:
The link you publish uses NTP - it's one of the many NTP server/client software available.  NTP is not a push protocol. :(

I've just noticed I've severely messed up.  I am sorry, but net time does not do as I described!

The only way around this is to use WMI (works only with Windows 2000/XP/2003, IIRC) to force the other machine to perform the net time/NTP transaction at a particular time.  I don't know how to use WMI, let alone program for it - I only know it's a possibility.

Again, my apologies for the misinformation - I was thinking of a login script (which is the way I usually implement it)... but that's a client pull, not a server push. :(
0
 
CodedKAuthor Commented:
Thanks for your time :)
0
 
geobulCommented:
Hi,

>How can i do this within my application?

Without your own client/server application already installed on all computers - I don't know. But that doesn't make sense because you'll need to install that application manually on all computers which is the same effort as setting them to use the time server directly. I do that manually on every computer in the LAN.

Regards, Geo
0
 
CodedKAuthor Commented:
Hi geobul.

There are many application that can take control of a remote system and do several things...
For example shutting down a pc in lan, Move the mouse etc
Is there any way that i can take control of the time...?
Without installing anything... just take control of the remote system and change the time.
Thanks..
0
 
CodedKAuthor Commented:
:/ The question is getting old..
I posted for a refund...
0
 
geobulCommented:
Sometimes there are things that cannot be done. As I already said you have to set time synchronization on every workstation.
0
 
CodedKAuthor Commented:
:) You are right geobul..
I'll split the points...

But ... is it possible at least to get the time of a different pc in lan?
Not change it ... just see the time..
??
0
 
geobulCommented:
Hi,

Yes, it's possible but for NT,2000, XP, etc. (NT based platform) I think. Here it is:

type

  TNetAPIStatus = DWord;

  TTimeOfDayInfo = record
    tod_elapsedt,
    tod_msecs,
    tod_hours,
    tod_mins,
    tod_secs,
    tod_hunds: DWord;
    tod_timezone: LongInt;
    tod_tinterval,
    tod_day,
    tod_month,
    tod_year,
    tod_weekday: DWord;
  end;

  PTimeOfDayInfo = ^TTimeOfDayInfo;

  function NetRemoteTOD(UncServerName: LPWSTR; BufferPtr: PTimeOfDayInfo): TNetAPIStatus; stdcall; external 'netapi32.dll';

function GetServerTime(Server: string): TDateTime;
var
  t: PTimeOfDayInfo;
begin
  NetRemoteTOD(PWideChar(WideString(Server)), @t);
  Result := EncodeDate(t^.tod_year, t^.tod_month, t^.tod_day) +
            EncodeTime(t^.tod_hours, t^.tod_mins, t^.tod_secs, t^.tod_hunds * 10) - (t^.tod_timezone/1440);
end;

// usage
procedure TForm1.Button1Click(Sender: TObject);
var
  dt: TDateTime;
begin
  dt := GetServerTime(Edit1.Text);
  Edit2.Text := FormatDateTime('dd.mm.yyyy hh:nn:ss', dt);
end;

Regards, Geo
0
 
CodedKAuthor Commented:
Thank u very much Geo.. :)
0
 
geobulCommented:
You are welcome :-)
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now