Skip to content

Instantly share code, notes, and snippets.

@Fiaxhs
Last active October 8, 2021 06:52
Show Gist options
  • Save Fiaxhs/61aa9b7d9ea69e94a2c9 to your computer and use it in GitHub Desktop.
Save Fiaxhs/61aa9b7d9ea69e94a2c9 to your computer and use it in GitHub Desktop.
Force date and time internet sync - Windows bat
REM Create a bat file with the following 4 lines (feel free to change ntp servers below)
w32tm /config /syncfromflags:manual /manualpeerlist:"ntp.unice.fr, ntp.accelance.net"
net start w32time
w32tm /resync
w32tm /resync
REM Yep, often the first time fails, just do it again.
REM Save as .bat file, and create a scheduled task at each logon.
REM - You can do this with Task Scheduler by hand, be sure to tick "Run as administrator"
REM - Or open a command as administrator and enter this:
REM schtasks /create /sc onlogon /tn ForceSyncTime /rl highest /tr "C:\your\path\to\your\file.bat"
@vahidshukurov1988
Copy link

How i can use this command in batch file
schtasks /create /sc onlogon /tn ForceSyncTime /rl highest /tr "C:\your\path\to\your\file.bat"

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