20110620

Synchronize Local Time With Scripting


Local Time Synchronizing with scripting
Following scripting will allow you to change your local time and synchronize with your server. Below scrip will help to local time and synchronize with your server; copy script to notepad and save .bat and run
@Echo Off
CLS ; Clears the screen
Set myserver=ServerName
Echo Syncing the time with %myserver%…
Net Time \\%myserver% /set /yes
If %errorlevel% NEQ 0 CLS && Goto Domain
CLS && Echo Sync Successful
Goto End
:domain
Echo Searching the local domain for a time-server…
Net Time /set /yes
If %errorlevel% EQU 0 CLS && Echo Sync Successful && Goto End
CLS && Echo Time Sync Error
:End
Here, myserver is a variable containing the name of the time source server; NEQ is the “not equal to” operator; and && allows you to run a second command after the first has completed.
Synchronizing the local system to a central time source allows you to perform enterprise-wide tasks simultaneously. The basic syntax to synchronize the local clock with a specified time source is as follows:
Net Time \\server/commands
Here, \\server is the name of the time source server to sync with. This parameter is only necessary when syncing with a specific server. If this parameter is omitted (Net Time), the system will search the local domain for a time source server. /commands are any of the following parameters:
  • /SET—Sets the local time to the time source server
  • /Y—Forces to sync the time with the server specified, regardless of whether the server is a time source server or not
  • /DOMAIN:domainname—Searches the specified domain for a time source server

No comments:

Post a Comment