<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Edi Naic</title>
    <description>The latest articles on DEV Community by Edi Naic (@edwin_gichira_92748e19bb6).</description>
    <link>https://dev.to/edwin_gichira_92748e19bb6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1613961%2F486ad758-f962-46b3-8654-a4bf76634e72.png</url>
      <title>DEV Community: Edi Naic</title>
      <link>https://dev.to/edwin_gichira_92748e19bb6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/edwin_gichira_92748e19bb6"/>
    <language>en</language>
    <item>
      <title>Automatic Windows Resync time after reboot: Auto Clock Sync with Dead CMOS and Battery.</title>
      <dc:creator>Edi Naic</dc:creator>
      <pubDate>Wed, 12 Jun 2024 09:38:42 +0000</pubDate>
      <link>https://dev.to/edwin_gichira_92748e19bb6/fixing-laptop-time-issues-solving-clock-problems-with-dead-cmos-and-battery-8ef</link>
      <guid>https://dev.to/edwin_gichira_92748e19bb6/fixing-laptop-time-issues-solving-clock-problems-with-dead-cmos-and-battery-8ef</guid>
      <description>&lt;h2&gt;
  
  
  OPTION 1. &lt;em&gt;Most viable solution 💯&lt;/em&gt;.
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Open Task Scheduler:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Press  Win + R  to open the Run dialog.&lt;/p&gt;

&lt;p&gt;Type  &lt;em&gt;taskschd.msc&lt;/em&gt;  and press Enter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Create a new task:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;em&gt;"Actions"&lt;/em&gt; tab then click either &lt;em&gt;"Create Basic Task..."&lt;/em&gt; or &lt;em&gt;"Create Task"&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Set up the task:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Name it something like "&lt;em&gt;Time Sync on Startup&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;Under the &lt;em&gt;Triggers&lt;/em&gt; tab, click &lt;em&gt;New&lt;/em&gt; then select when to begin the task as "At startup", and click &lt;em&gt;OK&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For Action under the action tab, select "Start a program".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Specify program/script:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the Program/script field, type &lt;code&gt;w32tm&lt;/code&gt;. In Add arguments (optional), type &lt;code&gt;/resync&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The final setup should look something like this:&lt;/p&gt;

&lt;p&gt;Program/script: &lt;code&gt;w32tm&lt;/code&gt;Add arguments (optional): &lt;code&gt;/resync&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This tells Windows to use its &lt;strong&gt;built-in time synchronization command&lt;/strong&gt; (w32tm /resync) whenever your laptop starts.&lt;/p&gt;

&lt;p&gt;Click Finish or Ok depending on whether you selected to create a Basic task or a Task.&lt;/p&gt;

&lt;h2&gt;
  
  
  OPTION 2
&lt;/h2&gt;

&lt;p&gt;Not a fully viable solution due to some access level restrictions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 1: Create a PowerShell Script&lt;br&gt;
&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open Notepad or any text editor.&lt;/li&gt;
&lt;li&gt;Copy and paste the following PowerShell script into the text editor:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# PowerShell script to sync system time with an internet time server
Try {
    Write-Output "Updating system time from time.windows.com..."

    # Start the Windows Time service if it is not running
    $service = Get-Service -Name w32time
    If ($service.Status -ne 'Running') {
        Start-Service -Name w32time
        Start-Sleep -Seconds 5  # Give the service time to start
    }

    # Update time using W32tm (Windows Time Service)
    w32tm /config /manualpeerlist:"time.windows.com" /syncfromflags:manual /reliable:YES /update
    Start-Sleep -Seconds 5  # Wait for a few seconds to ensure the configuration is updated
    w32tm /resync
    Write-Output "System time updated successfully."
} Catch {
    Write-Output "Failed to update system time."
    $_.Exception.Message
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file with a &lt;em&gt;.ps1&lt;/em&gt; extension, for example, &lt;em&gt;UpdateTime.ps1&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Step 2: Create a Scheduled Task&lt;br&gt;
&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Task Scheduler:
Press &lt;em&gt;Windows + R&lt;/em&gt;, type &lt;em&gt;taskschd.msc&lt;/em&gt;, and press Enter.&lt;/li&gt;
&lt;li&gt;Create a New Task:
In the Task Scheduler, click Create Task in the Actions pane on the right.&lt;/li&gt;
&lt;li&gt;General Tab:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Name your task, e.g., "&lt;em&gt;Update System Time on Startup&lt;/em&gt;".&lt;br&gt;
Choose "&lt;em&gt;Run whether the user is logged on or not&lt;/em&gt;".&lt;br&gt;
Check "&lt;em&gt;Run with highest privileges&lt;/em&gt;".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Triggers Tab:&lt;br&gt;
Click New to create a new trigger.&lt;br&gt;
From the Begin the task dropdown menu, select "At startup".&lt;br&gt;
Click OK to save the trigger.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Actions Tab:&lt;br&gt;
Click _New _to create a new action.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From the Action dropdown menu, select "&lt;em&gt;Start a program&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;In the Program/script box, type &lt;em&gt;powershell.exe&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In the Add arguments (optional) box, type the following (replace the path with the path to your script):&lt;/p&gt;

&lt;p&gt;&lt;em&gt;powershell&lt;/em&gt;&lt;br&gt;
&lt;code&gt;-File "C:\autoTimebyEd\UpdateTime.ps1"&lt;/code&gt;&lt;br&gt;
Click OK to save the action.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Conditions Tab:&lt;br&gt;
Uncheck "Start the task only if the computer is on AC power" if you want the task to run on battery power as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Settings Tab:&lt;br&gt;
Check "Allow task to be run on demand".&lt;br&gt;
Optionally, you can adjust other settings as needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Save the Task:&lt;br&gt;
Click OK to save the task.&lt;br&gt;
You may be prompted to enter your user account password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Testing the Task&lt;br&gt;
Run the Task Manually from the Task Scheduler:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Task Scheduler, locate the task you created.&lt;br&gt;
Right-click the task and select "&lt;em&gt;Run&lt;/em&gt;".&lt;br&gt;
Check if the system time updates correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Restart Your Laptop:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Restart your laptop to ensure the script runs at startup and updates the time.
Following these steps, your laptop should automatically fetch and update the system time from &lt;em&gt;time.windows.com&lt;/em&gt; each time it powers on. 
This setup ensures your system clock is always accurate without requiring manual intervention.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
