Solved

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

Posted on 2004-04-28
10
519 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
  • 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now