Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-28
10
Medium Priority
?
527 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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

926 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