Skip to content

Instantly share code, notes, and snippets.

Last active October 29, 2023 15:26
  • Star 26 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Rem run as administrator
@echo on & @setlocal enableextensions
@echo =========================
@echo Turn off the time service
net stop w32time
@echo ======================================================================
@echo Set the SNTP (Simple Network Time Protocol) source for the time server
w32tm /config /syncfromflags:manual /manualpeerlist:""
@echo =============================================
@echo ... and then turn on the time service back on
net start w32time
@echo =============================================
@echo Tell the time sync service to use the changes
w32tm /config /update
@echo =======================================================
@echo Reset the local computer's time against the time server
w32tm /resync /rediscover
@endlocal & @goto :EOF
Copy link

Baanin commented Apr 25, 2017


Copy link

yangloc commented May 22, 2017

Thanks a lot!

Copy link

mathandy commented Jun 3, 2017

To others: make sure you "run as admin".
@thedom85 Thanks!

Copy link


Copy link

z00sts commented Mar 12, 2018


Copy link


Copy link

ediband commented Feb 21, 2019

Great script, thx!

Copy link

Work on Win10

Copy link

Thank you, now I can keep time!

Copy link

can i make a scheduled task using this?

Copy link

@ahmedmoselhi Yes, you can.

Copy link

If you need to run this every time the computer boots, press the Windows key + R, type shell:startup. Then you can create a shortcut. Enter the shortcut's Properties, click Advanced, and select Run as administrator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment