Last active
May 29, 2020 08:01
-
-
Save n1kk/d7801e3fb3e8b4100f3d6df28f949d72 to your computer and use it in GitHub Desktop.
Force windows to update time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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