Skip to content
WJunction - Webmaster Forum

Synchronize Windows Server 2008 time during startup

Status
Not open for further replies.
Click in the clock with the right mouse button and select Adjust date/time, then go to the Internet Time tab, hit Change settings and Update now. If it works, we can proceed.

Create a file with the following contents in C:\sync-clock.php
PHP:
<?php
// Attempt resync
system('w32tm /resync', $return_var);

while( $return_var !== 0 )
{
	// Sleep to avoid excessive looping
	sleep(10);

	// Attempt resync
	system('w32tm /resync', $return_var);
}

// Successful exit
exit(0);
?>

Run Computer Management ( compmgmt.msc ) from Control Panel > System and Security > Administrative Tools.

Go to Task Scheduler Library and Create a Basic Task with When the computer starts as Trigger.

Action will be to Start a Program, Input the path to your php executable (php.exe) in Program/Script.
Add Arguments: -n -f "C:\sync-clock.php"

After task is created, edit its properties:
Change User or Group and type SYSTEM, then confirm
Tick Run with highest privileges
Confirm the changes.
 
Last edited:

2 comments

Status
Not open for further replies.

About the author

NewEraCracker
Active Member · Joined
The Cracker of New Era
1,335
Messages
203
Reactions
63
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom