Keep your Windows Clock synchronized.

ClockSync is a simple command-line script to keep your Windows clock synchronized.
In some systems and for different causes, Windows clock can frequently go out of sync.
This small tool should solve this problem.
ClockSync is written in Batch language.

If you’re looking for a program to keep your system time accurate, you’ve just found it!

  • Free
  • Open Source
  • Small: less then 2 kb
  • Fast and Easy to use
  • Works on any Windows from Win7 up to Win10, including Server editions.
    Both 32-bit and 64-bit OS are supported.
  1. Make sure you are connected to the Internet.
  2. Run ClockSync.bat file with administrator privileges.

ClockSync will automatically perform a first synchronization.
After that, it performs periodic synchronizations on a time interval.
By default, it synchronizes time each 10 minutes.

If you want to specify a custom resync interval, run the file with a “minutes” command parameter.
The following command, for example, synchronizes the clock every 60 minutes:
“ClockSync.bat 60”


ClockSync will keep your system clock accurate by performing periodic synchronizations with your default Internet Time Server.

If the Windows Time Service or Internet Time Synchronization were disabled, ClockSync will restart them.
This will help keeping your system clock accurate even when ClockSync is not running.

Source Code:

ClockSync.bat :

@echo off
echo * ClockSync v1.0
echo *

:: Check that we own administrator access level. 
echo [INFO] Checking Access Level...
net session >nul 2>&1
if %errorLevel% == 0 (
	:: We have the necessary rights, go forward
	echo [INFO] Administrative Access confirmed.
) else (
	:: Error, insufficient privileges. Exit program.
	echo [ERROR] Insufficient Access Level. Please restart script with administrative permission.
	echo Press any key to exit...
	pause > nul

:: Check command-line parameter.
:: User can specify any number of minutes for the Resync interval.
:: If there is no user-specified parameter, default one is used.
set /A minutes = 10
if not "%1" == "" (
	set /A minutes=%1

:: Synchronize Clock
:: Use /force parameter to bypass "time change too big" error
w32tm /resync /force
if not errorlevel 0 (
	:: If Error, restart time service
    echo [WARNING] Time Service error. Restarting service...
	net stop w32time
    w32tm /unregister
    w32tm /register
    net start w32time
	w32tm /resync /force
	if not errorlevel 0 (
		:: Unknown error, exit program.
		echo [ERROR] Unknown error.
		echo Press any key to exit...
		pause > nul
echo [SUCCESS] Clock successfully synchronized!
echo Date: %date%
echo Time: %time%

:: Sleep
set /A seconds = %minutes% * 60
echo [INFO] Sleeping for %minutes% minutes until next synchronization...
ping -n %seconds% > nul

:: Repeat
goto loop