Skip to content

Instantly share code, notes, and snippets.

@n1kk
Last active May 29, 2020 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1kk/d7801e3fb3e8b4100f3d6df28f949d72 to your computer and use it in GitHub Desktop.
Save n1kk/d7801e3fb3e8b4100f3d6df28f949d72 to your computer and use it in GitHub Desktop.
Force windows to update time
REM *** run as ADMINISTRATOR !
REM Forces windows to update time
@echo off
set retryCount=0
echo Resync END
:SyncStart
if %retryCount% == 10 goto SyncFailed
set /A retryCount=retryCount + 1
REM *** Resync the system clock
echo resyncing, attempt %retryCount%
w32tm /resync
if errorlevel 1 goto SyncDelay
if errorlevel 0 goto SyncEnd
:SyncDelay
REM *** If unsuccessful, wait, then retry
echo failed, waiting before retry
PING localhost -n 6 >NUL
goto SyncStart
:SyncFailed
echo "resync failed, make sure shell is running as administrator"
pause
:SyncEnd
echo "Resync END"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment