A robust utility suite built with Windows Batch (.bat) and VBScript (.vbs) designed to accurately fetch, synchronize, and manage system time using online time APIs. Specially optimized for older Windows systems (such as Windows 7) where native time synchronization services might fail or need custom automation.
- Role: The core script responsible for updating and setting the system's date and time.
- Mechanism: It connects to an online time API (
https://timeapi.io/api/time/current/zone?timeZone=Africa/Cairo) to fetch precise, zone-specific time data. - Dependencies: Requires
curl.exeto execute network requests. By default, it looks forcurlinside the Git installation path, so make sure to update the path if your environment differs. - Error Handling Codes (via VBScript integration):
10001:curl.exe was not found at the specified path.10002:Could not fetch time. Check your internet connection.10003:Could not parse date from API response.10004:Failed to set system Date. Please Run as Administrator.10005:Failed to set system Time. Please Run as Administrator.
- Role: The primary manager script that controls, executes, and handles
fix_time.bat. - Arguments Supported:
silentors: Runs in silent mode (suppresses error dialogs/popups while still returning the correct error code).ignore-net-errorori: Ignores network-related failures (ideal for devices that are not constantly connected to the internet). Returns exit code0when triggered.delay(e.g.,/delay:10): Introduces a custom waiting period in seconds before executingfix_time.bat. If the script lacks administrator privileges, it will prompt the user before starting the countdown.
- Role: Automates the creation of a Windows Task Scheduler entry to run the time synchronization script seamlessly at system startup/logon.
- Arguments:
- Use
/defaultsor-yto automatically bypass prompts and apply default configurations.
- Use
- Interactive Prompts:
- Task Name: Defaults to
CustomTimeSync. - Delay Time: The preferred delay duration before execution.
- Task Name: Defaults to
- Under the Hood: Leverages Windows native
schtasksutility:schtasks /create /tn "%TASK_NAME%" /tr "wscript.exe "%SCRIPT_PATH%" /delay:%INPUT_DELAY%" /sc ONLOGON /rl HIGHEST /f```
- Role: A comprehensive management tool designed to handle background tasks effortlessly.
- Supported Operations: Create, run, enable, disable, delete, and query tasks.
- Privilege Requirements:
- Administrative privileges are mandatory for creating, deleting, and modifying states (such as enabling or disabling tasks).
- Ensure
curl.exepath inside the script matches your system setup (typically mapped from your Git directory). - Run
fix_time.batmanually with Administrator privileges to test synchronization. - Use
add_task.batto schedule it automatically on logon. - Use
manage_task.batwhenever you need to check, run, or alter the scheduled synchronization tasks.