Solution Only for Windows 7
Earlier, we recommended creating a batch file to avoid the need for error-prone (typos) text entry in the console. Here is an example of a very comfortable approach using a command file (cmd).
By entering the menu number and pressing the Enter key, the specified commands are executed.
Example If you wish to view the current configuration of the Window time service, press 8 and confirm with Enter. The current configuration appears.
To return to the selection menu, press any key.
Here is an excerpt for executing the commands:
Run the Command File
If you want to use this practical solution:
-
Open Notepad or another text editor.
-
Copy the contents of the box below into the editor.
-
Save the file as a CMD file. For example: TIMECONFIG.cmd.
-
Double-click to run the command file.
IMPORTANT: This file may only be run in Windows 7. Execute the file and the associated commands at your own risk!
Contents of the Command File
Example
@echo off
title Windows 7 Time Tool Geutebrueck GmbH
color 1A
rem mode con: cols=100 lines=60
mode con: cols=120
echo.
rem check UAC
dism>NUL
If %errorlevel% NEQ 0 GOTO :INFO
:menu
cls
echo.
echo.
echo Configuration Windows Time Service on local computer:
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ ³
echo ³ CONFIG ³
echo ³ -------------------------------- ³
echo ³ 1 = TIME SERVER SETTING ³
echo ³ 2 = TIME CLIENT SETTING ³
echo ³ ³
echo ³ TEST ³
echo ³ -------------------------------- ³
echo ³ 3 = SYNC TIME MANUAL ³
echo ³ 4 = INFORMATION ³
echo ³ 5 = TIME MONITOR ³
echo ³ ³
echo ³ TOOL ³
echo ³ -------------------------------- ³
echo ³ 6 = RESTORE DEFAULT SETTINGS ³
echo ³ 7 = FIREWAL PORT UDP 123 SHARING ³
echo ³ 8 = TIME SERVICE CONFIG ³
echo ³ 9 = HELP ³
echo ³ ³
echo ³ ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
echo.
Set /P sel="SELECT:"
echo.
For %%a In (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) Do if %sel%==%%a Goto SELECT_%%a
echo SELECT ERROR !
pause>NUL
goto menu
:SELECT_1
rem server setting
echo Setting to Time Server and set local CMOS Clock ...
net stop w32time
set Key="HKLM\SYSTEM\CurrentControlSet\Services\W32Time"
reg add %key%\TimeProviders\NTPClient /v Enabled /t REG_DWORD /d "0" /f
reg add %key%\TimeProviders\NTPServer /v Enabled /t REG_DWORD /d "1" /f
reg add %key%\Config /v AnnounceFlags /t REG_DWORD /d "5" /f
reg add %key% /v Start /t REG_DWORD /d "2" /f
net start w32time
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_2
rem client setting
set /P NTP=SYNCHRONIZE WITH AN TIME SERVER (SET NAME OR IP-ADRESS):
set Key="HKLM\SYSTEM\CurrentControlSet\Services\W32Time"
reg add %key% /v Start /t REG_DWORD /d "2" /f
net stop w32time
net start w32time
w32tm /config /manualpeerlist:%NTP% /update
w32tm /resync
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_3
rem manuel time sync
w32tm /resync
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_4
rem time service information
echo Time Source:
echo ------------------------
w32tm /query /source /verbose
echo.
echo Time Configuration
echo ------------------------
w32tm /query /configuration
echo.
echo Time Status:
echo ------------------------
w32tm /query /status /verbose
echo Peers:
echo ------------------------
w32tm /query /peers
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_5
rem time monitor
echo Display Offset between this computer
echo and another computer
set /P comp=computer(SET NAME OR IP-ADRESS):
cls
title Display Offset between this computer %comp%
w32tm /stripchart /computer:%comp%
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_6
rem restore default
net stop w32time
rem MS (w32tm error) must be ignored!!
w32tm /unregister
w32tm /unregister
w32tm /register
net start w32time
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_7
rem firewall configuration
call :FIREWALL
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_8
rem time sevice
call :SERVICETIME
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:SELECT_9
rem w32tm help
w32tm
echo.
echo Press any key back to menu...
pause>NUL
GOTO :menu
:FIREWALL
echo Port sharing for Windows Time Service UDP 123 in
netsh advfirewall firewall add rule name="Time Server IN" dir=in action=allow description="NTP 123 IN" enable=yes profile=any localport=123 remoteport=any protocol=UDP
echo Port sharing for Windows Time Service UDP 123 out
netsh advfirewall firewall add rule name="Time Server OUT" dir=out action=allow description="NTP 123 OUT" enable=no profile=any localport=123 remoteport=any protocol=UDP
exit /b
:SERVICETIME
rem config and start time service
sc qc w32time
sc config w32time start= auto
sc start w32time
sc qtriggerinfo w32time
SC triggerinfo w32time delete
sc qtriggerinfo w32time
exit /b
:INFO
title Warning!
echo.
echo.
echo *** WARNING!
echo.
echo.
echo You may need to launch an elevated Command Prompt (right-ckick Run as administrator)
echo.
echo.
echo.
echo.
pause>NUL
echo.