Skip to content

kakaa2993/Set-Time-Automatically-in-Win-10

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Set Time Automatically In Windows 10

How to force Windows 10 time to synch with a time serve?

Languages Top Language Repository Size Made By


What This Script Made For?

  • This code was created by Belamiri Zakarya to force Win 10 to sync the time with the time server in Windows 10 automatically without the user needing to do it manually.
  • The script inspired from this question.
  • Because in some machines that have Win 10 the time display isn't correct, so you need to change it every time you restart your PC with manual work.
  • This script can fix the problem automatically with a click.

The Requirement?

  • This script needs only the connection to the internet to work!

How To Use This Script?

  • Just run the script as administrator.

and voila! That is all that you need.

Can I Use The Script Automatically?

You can make the script run automatically using Task Scheduler from Windows, here is a video showing you how you can use it manually on YouTube.

Or you can also do it with cmd:

  • To create a task that runs a batch script "at log in" for any user and "as administrator" using the command line:
schtasks /create /tn "Name_of_Task" /sc onlogon /ru SYSTEM /rl HIGHEST /tr "C:\path\to\your\batch\sync_time_win.bat"

Explanation of the command:

  • /sc onlogon: the task should run when any user logs on.
  • /ru SYSTEM: The task should run under the SYSTEM account, which has administrative privileges.
  • /rl HIGHEST: Sets the privilege level to the highest available, effectively running the task as an administrator.
  • /tr "C:\path\to\your\batch\sync_time_win.bat": Specifies the path to the batch script that you want to run.

Replace "Name_of_Task" with the desired name for your task and "C:\path\to\your\batch\sync_time_win.bat" with the actual path to your batch script.

After running this command, the task will be created in Task Scheduler, and it will execute the specified batch script whenever any user logs on, running with administrative privileges. Here's a table summarizing the available options for the schtasks /create command in Windows:

Option Description
/tn Specifies the name of the task.
/sc Specifies the schedule type (e.g., ONLOGON, DAILY, WEEKLY, MONTHLY, etc.).
/ru Specifies the user account to run the task under. Use SYSTEM for the highest privileges.
/rl Specifies the logon type (e.g., HIGHEST, LIMITED).
/tr Specifies the path to the program or script to be run by the task.
/st Specifies the start time for the task (if applicable, based on the chosen schedule).
/sd Specifies the start date for the task.
/ed Specifies the end date for the task.
/et Specifies the end time for the task.
/mo Specifies the modifier for recurrence (e.g., 1, 2, ..., 365).
/i Specifies the idle time to wait before running the task (only for ONIDLE trigger).
/c Specifies the comment for the task.
/f Forces the creation of the task even if errors occur.
/it Sets the task to be interactive (must only be used with /sc ONLOGON).
/s Specifies the remote server to connect to for creating the task.
/u Specifies the user context under which the task should run.
/p Specifies the password for the user specified with /u.
/triggers Specifies one or more triggers for the task.
/xml Specifies the XML file containing the task definition.

These are the main options for the schtasks /create command. You can combine them to customize the task according to your requirements.


Made by Belamiri Zakarya 👋 Get in touch!

About

How to force Windows 10 time to synch with a time serve?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published