I have a very old laptop, it is out of battery for CMOS, so each time a unplug it , the time is jump back to 2002 (i guest this is its birth year , I had to sync its time everytime I turn it on. It’s old so it is not easy to open its components and replace the CMOS battery.
So I think, that must has some programs to sync the time for this case,right? And I googled it. But most of these programs required you to install it. I dont like this, I thought it is a very simple job, no need to install a program, just find some ones can run directly. In several hours, I could not find any tool which is small and run directly as I want. I even though that I will code one.
Luckily, I fought this very small one, which will sync your computer’time with internet time. It’s very small, does not have a UI, too. I like it.
All I need to do is quite simple: I wrote a small batch file with some commands, and put this batch file to startup folder.
At first, it has only one command:
“cmdtime3.exe” /q sync /m:7200000
It runs well, except sometime, when the LAN to internet was not ready so It could not sync time.
So I put more commands into the batch file, the idea is wait until internet connection is ready and sync after that. I use ping command to wait until internet is ok:
ping -n 1 google.com
if %errorlevel% == 0 goto remote_desktop
rem wait for 10 seconds before trying again
@echo Waiting 10 seconds…
ping -n 10 127.0.0.1 > nul
rem loopback to start
And after these ones is the suync time command.
You can download all here: cmdtime
Hope this can help someone wants to find a simple and small solution.
Leave a Reply