- Windows Scheduled Tasks
- Batch Files
- Windows 10
This one is for those frustrated office workers with a certian lenovo work laptop that loses its clock! Mine is a Lenovo ThinkPad X1 Carbon 7th Gen, but reading support forms, most support agents are helping with their applicaiton rather than the root cause!
Advocate for yourself! If you keep having issues, and you’re a consientious note taker, please teach me how you are able to keep that organized! For the rest of you, I am sharing my toys!
This batch file reaches out to the internet and gets the time, logging it with the time on the windows clock. This file can be opened in excel to even show the tightest bean counter why your laptop is malfunctioning, but you can never seem to show IT!
How it works
By using Windows Scheduled Tasks, we can link the execution of our troubleshooting script to certain actions. In my case, I chose a bunch! By including the user triggered event of “workstation unlock” I can take logs whenever I have the issue by locking and unlocking. There are many other options!
Another event which I track seperately is group policy 1126, clock sync with domain issues
Time.bat’s code
@echo off
::#mikesolo 101221
::#script to check local time vs an outside clock
cd c:/time
::Dont use https when having time issues
set url=http://worldtimeapi.org/api/timezone/America/New_York.txt
set tstart=%TIME%
curl -v %url% |findstr datetime | findstr \-04:00 > now.txt
::This is statically coded, Change the 2nd find str to your time offset
( set /p world=
) < now.txt
set mydate=%DATE%
set mytime=%TIME%
echo $$$$$
::Parse and remove junk from the world time
set world=%world:~10,-13%
set world=%world:,=%
:: Fix for issue 6, Always replace the world variables's , with nothing.
::In the failure mode this does something, otherwise nothing
set wdate=%world:~0,-9%
set wtime=%world:~11%
echo %world%,%wdate%,%mydate%,%tstart%,%wtime%,%mytime%,%1
echo %world%,%wdate%,%mydate%,%tstart%,%wtime%,%mytime%,%1 >> Log.csv
:: Install by setting a task by running cmd taskschd.msc
:: I used at login and boot