Tag Archives: Dumb Hacks

Miscellany

Dumb Hacks: Help!! My dinosaur Windows computer doesn’t keep time anymore, but I’m too lazy/afraid/cheap to change the CMOS battery!  

CMOS event for dinosaur tech.

Deep inside old Windows desktop computers is a CMOS battery that helps Windows keep the correct time after the computer has been turned off or put to sleep.

When that battery eventually dies, Windows will not have the correct time when the computer comes back from sleep or from being turned off.

There are actually plenty of reasons one might not want to bother changing that battery out.  I figured out how to make the computer sync with internet time when it powers up or when it comes back from sleep.  In doing so, time synchronization is done completely through the Windows OS, and it only requires internet access.  For a simple use case like mine, that was the superior solution.

What actually didn’t make sense was how scattered around the solution for this seemed to be.  Everyone seemed to have this same problem with their old desktop computers, and 99.999% of the time it’s a dead CMOS battery – yet there didn’t seem to be one comprehensive solution posted anywhere.  I had to pick up the different parts of the solution from different web articles buffet-style.

Below is a solution for Windows 10 that works for me.  I’m not an expert in most of what’s going on, and I can’t guarantee there won’t be rare edge cases that come up and cause problems.  What I can say is it solves the problem for me.

  1. Copy the following block of text and paste it into an XML file somewhere on your computer.  (Alternatively, you can just download it as the following text file [Wordpress doesn’t allow standard XML file downloads].  Then, change the file extension from .txt to .xml, or alternatively, leave the file extension alone and in step #5 broaden the search filter from ‘XML files’ to ‘All files’ and simply navigate to the text file.)
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2021-09-28T22:55:59.1253844</Date>
    <Author>Admin-PC\Admin</Author>
    <Description>Syncs time upon power up or wake from sleep.</Description>
    <URI>\Microsoft\Windows\Time Synchronization\SyncTimeOnPowerOrWake</URI>
  </RegistrationInfo>
  <Triggers>
    <EventTrigger>
      <Enabled>true</Enabled>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="System"&gt;&lt;Select Path="System"&gt;*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and EventID=107]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    </EventTrigger>
    <BootTrigger>
      <Enabled>true</Enabled>
    </BootTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-19</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>%windir%\system32\sc.exe</Command>
      <Arguments>start w32time task_started</Arguments>
    </Exec>
    <Exec>
      <Command>%windir%\system32\w32tm.exe</Command>
      <Arguments>/resync</Arguments>
    </Exec>
  </Actions>
</Task>

2. Open the Windows Task Scheduler.  Typing “Task Scheduler” in the Windows search bar should bring it up.

3. If you want to keep this task organized, expand down to: Task Scheduler Library | Microsoft | Windows | Time Synchronization.

4. Right click on the Time Synchronization folder and select ‘Import Task…’

5. Navigate to that XML file you saved on your computer and open that file.

6. You will get a dialog with multiple tabs.  You can review and edit all the properties of the new task.  If you want to proceed with it, then click ‘OK’.  Clicking ‘Cancel’ will abort the entire process.

Once you add the task, it will run whenever the computer powers up or when it wakes up from sleep.  This should sync your local Windows OS time with internet time, reliably, and irrespective of your dead CMOS battery.

Finally, you can always right click on this new task and simply click ‘Delete’ if you want to get rid of it.