Solved

query Time Server & set(ie NET TIME \\<SERVER> /SET /Y)

Posted on 2004-04-28
10
523 Views
Last Modified: 2008-02-26
As the subject heading says, I have a client/server setup in where log files are time sensitive and therefore need to synchronize the time between the server and client machine when one of the client machine reboots.

I know how to set the sntp server :

net time /setsntp:<timeserver>

and how to sync the time (assuming it does this on boot as well)

NET TIME \\<SERVER> /SET /Y

how can I query the network and find  a list of time servers so that I can give the user a choice of which one to use?

Thanks.

0
Comment
Question by:bswiftly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10948509
I don't know of ways of enumerating external servers, but there are lists:

Public NTP Time Servers
http://www.eecis.udel.edu/~mills/ntp/servers.html

Bob
0
 
LVL 1

Author Comment

by:bswiftly
ID: 10960411
i am interested in enumerating time servers on the local netowrk.. not remote.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10961320
Aaah, a completely different story.

I have some code in VB6 that used NetServerEnum to enumerate SQL servers, and other types of servers as needed.  There is a bit that indicates TimeSource, so it would be easy to modify.  Unfortunately, since I didn't have a need to run this in .NET yet, I haven't converted this.  I tried to do that this morning, and failed, as it didn't find anything.  There are significant differences in the "managed" world of .NET and the "unmanaged" world of Windows API, so it might take me some time.

Bob
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 1

Author Comment

by:bswiftly
ID: 11008493
if you want i can give you partial points for effort..because I solved the problem  and no one posted an answer that I was looking for.  otherwise I'm going to clean this thread up.

thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11008499
Curious how you solved your problem?

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11008507
Points not too important here.  Interested in learning.

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11008734
I would like to see a solution to this question.  If one is provided, then it can be PAQ'ed, otherwise delete.

Bob
0
 
LVL 1

Author Comment

by:bswiftly
ID: 11008803
I didn't really solve it the way I wanted to.  Its still not even 100% robust.

I went through and found the differences between the xp version of dos and the one in win2k.  

this is the chunk of the select statement that  writes the batch file.  with xp i didn't use the w32tm command because it seemd to work better without it. but with xp you can't set a 'period' for it to re-sync.... i assume it does this automatically?

                    Case 0 'Win2k
                        s.WriteLine("NET TIME /SETSNTP:" & timeServer)
                        s.WriteLine("net stop w32time")
                        s.WriteLine("w32tm -once -period 1440")
                        s.WriteLine("net start w32time")

                    Case 1 'WinXP
                        s.WriteLine("NET TIME /SETSNTP:" & timeServer)
                        s.WriteLine("NET TIME /SET /Y")




however I did not find a way of enumerating any time servers on the system.  
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 11034749
Closed, 125 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question