Solved

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

Posted on 2004-04-28
10
520 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get list of word ducuments in a folder 10 36
Visual Studio editor? 1 38
Run time Error 4 35
Where can I ask about my ASP.NET MVC project? 6 23
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

18 Experts available now in Live!

Get 1:1 Help Now