Difference between revisions of "NTP client configuration"
From WPKG | Open Source Software Deployment and Distribution
m |
m (correct xml synxtax error) |
||
Line 6: | Line 6: | ||
<install cmd='cmd /c net time /setsntp:192.168.0.1' /> | <install cmd='cmd /c net time /setsntp:192.168.0.1' /> | ||
<install cmd='cmd /c net time \\192.168.0.1 /set /yes' /> | <install cmd='cmd /c net time \\192.168.0.1 /set /yes' /> | ||
− | <install cmd='cmd /c net stop w32time & net start w32time' /> | + | <install cmd='cmd /c net stop w32time & net start w32time' /> |
<install cmd='cmd /c w32tm /resync /nowait' /> | <install cmd='cmd /c w32tm /resync /nowait' /> | ||
<remove cmd='cmd /c net time /setsntp:time.windows.com' /> | <remove cmd='cmd /c net time /setsntp:time.windows.com' /> | ||
− | <remove cmd='cmd /c net stop w32time & net start w32time' /> | + | <remove cmd='cmd /c net stop w32time & net start w32time' /> |
<remove cmd='cmd /c w32tm /resync /nowait' /> | <remove cmd='cmd /c w32tm /resync /nowait' /> | ||
</package> | </package> | ||
</source> | </source> | ||
+ | |||
+ | Note: You must use & in place of & within cmd variable expression of xml file else you get the error: "Whitespace is not allowed at this location." | ||
or: | or: |
Revision as of 23:33, 15 February 2011
How to enable or disable NTP client on Windows.
<package id="ntp-client" name="NTP time synchronization" revision="1" priority="999" reboot="false" execute="once">
<install cmd='cmd /c sc config w32time start= auto' />
<install cmd='cmd /c net time /setsntp:192.168.0.1' />
<install cmd='cmd /c net time \\192.168.0.1 /set /yes' />
<install cmd='cmd /c net stop w32time & net start w32time' />
<install cmd='cmd /c w32tm /resync /nowait' />
<remove cmd='cmd /c net time /setsntp:time.windows.com' />
<remove cmd='cmd /c net stop w32time & net start w32time' />
<remove cmd='cmd /c w32tm /resync /nowait' />
</package>
Note: You must use & in place of & within cmd variable expression of xml file else you get the error: "Whitespace is not allowed at this location."
or:
<package
id="ntp-client"
name="ntp client configuration"
revision="1"
reboot="false"
priority="1"
execute="once">
<install cmd="%SOFTWARE%\ntp\install.bat" />
<upgrade cmd="%SOFTWARE%\ntp\install.bat" />
<remove cmd="%SOFTWARE%\ntp\uninstall.bat" />
</package>
install.bat:
sc config w32time start= auto
net time /setsntp:192.168.0.100
net stop w32time & net start w32time
w32tm /resync /nowait
uninstall.bat:
net time /setsntp:time.windows.com
net stop w32time & net start w32time
w32tm /resync /nowait