Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I ensure the system time is always correct on every boot?
#6
(07-28-2025, 08:36 PM)bacevs Wrote:
(07-22-2025, 01:55 PM)admin Wrote: It doesn't automatically synchronize the time when the internet connection is stable?

No, it doesn’t auto sync for some reason. I’ve put together a PowerShell script with a 2-minute delayed startup (to give the network enough time to come online) to handle the sync.

PHP Code:
# Sync-WindowsTime.ps1 # Self-elevation block: Relaunch with admin rights if necessary if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()     ).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) {     Write-Host "Relaunching PowerShell as Administrator..."     $params = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""     Start-Process powershell.exe -Verb RunAs -ArgumentList $params     exit } # Check the status of Windows Time service $service = Get-Service -Name w32time -ErrorAction SilentlyContinue if ($null -eq $service) {     Write-Host "Windows Time service (w32time) not found."     exit 1 } if ($service.Status -ne 'Running') {     Write-Host "Windows Time service is not running. Starting the service..."     Start-Service -Name w32time     Start-Sleep -Seconds 2 } else {     Write-Host "Windows Time service is already running." } # Force time sync Write-Host "Forcing time synchronization..." w32tm /resync /force Write-Host "Time synchronization command executed." Start-Sleep -Seconds 2 exit

This seems like a very good solution. Thank you for sharing.
Reply


Messages In This Thread
RE: How can I ensure the system time is always correct on every boot? - by admin - 07-29-2025, 03:13 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)