W32TM - CMD


Overview

The w32tm command is a command-line tool used for displaying and configuring the time service in Windows. It is primarily utilized to diagnose issues with the Windows Time Service, synchronize time settings with time servers, and help maintain accurate system time across a network. It is most effective in environments requiring synchronized time for authentication protocols, logging, or other time-sensitive operations.

Syntax

The basic syntax for w32tm is:

w32tm [Command] [Options]

Where [Command] can be one of several subcommands such as /query, /config, /monitor, and /resync. Each subcommand has its own set of options that modify its behavior.

Options/Flags

/query

  • /status: Displays the current status of the Windows Time service.
  • /configuration: Shows the current configuration of the time service.

/config

  • /manualpeerlist: Sets the manual peer list to which the Windows Time service can synchronize.
  • /syncfromflags: Configures the time source from manual, domain hierarchy, or both.
  • /update: Informs the time service that the configuration has changed, prompting it to update its settings immediately.

/resync

  • /nowait: Initiates a resync without waiting for the command to complete.
  • /rediscover: Forces redetection of network-configured time sources before resynchronization.

Examples

  1. Query Time Service Status:
    w32tm /query /status
    
  2. Configure Time Service to Use Specific NTP Servers:
    w32tm /config /manualpeerlist:"192.168.1.5,0x8 192.168.1.6,0x8" /syncfromflags:manual /update
    
  3. Force Time Resynchronization:
    w32tm /resync
    

Common Issues

  • Access Denied: Ensure you have administrative privileges when executing commands that alter service configurations.
  • Service not running: Verify that the Windows Time service is running before attempting configurations or queries. Use net start w32time to start the service if necessary.

Integration

Combine w32tm with other CMD commands for more comprehensive scripts. For example, to check if the Windows Time service is running and sync the time if it isn’t:

sc query w32time | find "RUNNING" || (w32tm /resync)

This script uses the sc command to check the service status and conditionally triggers time resynchronization with w32tm if the service is not running.

  • Net: Use for starting or stopping services, including the Windows Time service net start w32time or net stop w32time.
  • Time: Displays system time.

Additional Resources: For more detailed information, refer to the official Microsoft documentation at Windows Time Service.