Force synchronization of the system date and time with the network at startup under Windows

When the computer tends to go out of sync with the network time (for example when switching from Linux to Windows in dual boot).

Create an UpdateTime.bat file

Paste the following lines into this file :

start /W net stop w32time
start /W net start w32time

start /W w32tm /resync

start /W net stop w32time
start /W net start w32time 

(note the sart launches a cmd command and the /W indicates that one waits for the execution of the command to finish before moving on to the next one)

LLaunch Scheduled tasks.

Click Create Task.

Type a name for example UpdateTime.
Check Run with maximum permissions.
In the Triggers tab choose a trigger event for example when system starts (if the computer is connected at startup for example if it is connected in Ethernet) or else On event (choose Basic, then choose Log: Microsoft-Windows-NetworkProfile/Operational, then choose Source: NetworkProfile, then enter an event ID like for example 10000).
In the Actions tab specify the UpdateTime.bat file to be executed.
In the Conditions tab choose the setting. (uncheck all)
On the Settings tab: check only : Allow the task to run on demand, Stop the task if it runs for more than 3 minutes, If the task does not finish at the requested time, force it to stop.

Now when starting or connecting to a network, the date and time are resynchronized with the network.