Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to verify the current NTP configuration on some Windows systems. Ideally, I'd like to be able to do this via command line instead of navigating through configuration screens (especially since I'm working on several different OS versions, and configuration screens tend to not always be in the same place across versions). I'm hoping to find a quick, memorable command that I can just punch into a CMD console to get the result. A batch file I can carry around with me will do just as well, though.

Specifically, I need the following:

  • Show whether or not the system is configured to receive time from an NTP server.
  • Show the NTP server(s) the system is receiving time from.
  • Show the time of the last synchronization.
  • Show the current time on the system.

What command(s) would be necessary to achieve these results? Whatever I use must be cross-compatible with Windows XP, 7, Server 2003, and Server 2008.

share|improve this question
    
I know to check time you can do "net time \\computername" to get the time of the remote pc. I don't think net time lets you view last sync though... however "net time ?" gives a set option, so it's like 1/2 of what your looking for. –  Kyle May 16 '12 at 13:26
    
@Kyle I just figured out that net time /querysntp shows the server. Getting the rest of it might be tricky. –  Iszi May 16 '12 at 13:33
add comment

3 Answers

In the command line, type

w32tm /query /configuration
w32tm /query /status
Time /T 

The first command will give you the configuration you have set up and the second will give you information such as stratum, leap indicator, precision, last sync, NTP server, poll interval. Third, time /T outputs the current system time.

Note: w32tm /query was first made available in the Windows Time client versions of Windows Vista, and Windows Server 2008. See Windows Time Service Tools and Settings

share|improve this answer
    
No good on XP. "The command /query is unknown." –  Iszi May 16 '12 at 16:07
add comment

From the command line you can get the info like this:

reg QUERY [\\machine\]HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters
reg QUERY [\\machine\]HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config

Seems like that should be enough at least to get going in that direction, that is, if I understood your question. AFAIK, the 'reg' command works on all these different platforms so long as you have the right services running.

share|improve this answer
add comment

Take a look at w32tm command-line tool. It can set & query config and report a /stripchart of the time offset with another computer.

share|improve this answer
    
The /query option is not available on XP. –  Iszi May 16 '12 at 16:08
1  
Try net time /querysntp. –  Fran May 16 '12 at 17:10
    
@Fran That works. I was hoping to get one command that was cross-platform, but it seems I might have to use two different ones - or write a batch file that includes platform detection to determine which command(s) to run. –  Iszi May 16 '12 at 17:14
    
@lszi In my scripts, I test for the existence of C:\users. If I find that folder, I know I'm on a post-XP box. –  Fran May 16 '12 at 19:24
    
@Fran Could you write your own answer that includes both commands? Also, what command would I use to check the last successful sync time for XP? –  Iszi Jun 6 '12 at 19:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.