Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Computer Date and Time Using NTP Server

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

I'm looking for a script that when run from a batch or script file, will set the computers date and time to a current date and time after looking it up using a NTP Server service.

I know there are probably better places to post this, but I also know that the guys here are extremely smart too and probably has the answer.

I've tried
1.
w32tm /config /manualpeerlist:128.138.141.172 /syncfromflags:manual
w32tm /update
w32tm /resync

and it reports the dte difference is too big.

2.
rem w32tm /config /syncfromflags:manual /manualpeerlist:0.time.windows.com,1.time-nw.nist.gov,2.time-a.nist.gov,3.time.nist.gov

3.
Here is the entire batch file I've been playing with and still no glory.

Code:
@echo off

date 1/16/2015

pause
rem The pauses are here so I can watch the date change...


rem SET TODAY=%date:~0,2%-%date:~4,2%-%date:~7,4%
rem echo %today%

rem time 15:00

date 11/03/2015

pause

rem	date 1/16/2015

REM setting date back to an older date
rem	DATE 11/03/2011
rem (echo start "" "C:\path to my program\myprogram.exe"
rem echo del ^%^0) >tempstart.bat
rem start "" tempstart.bat
REM Changing date back to todays date
rem ping 1.1.1.1 -n 1 -w 4000>nul
rem DATE %TODAY%

w32tm /config /manualpeerlist:128.138.141.172 /syncfromflags:manual 
w32tm /update
w32tm /resync 

rem w32tm /config /syncfromflags:manual /manualpeerlist:0.time.windows.com,1.time-nw.nist.gov,2.time-a.nist.gov,3.time.nist.gov

pause

Any ideas?
Stanley
 
Is this a Foxpro question?


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Mike,

>>Is this a Foxpro question?

No, but a technical question asked by a FoxPro developer and I mentioned that fact that it was and why I asked... When developing vfp apps, we are generally all over the board in terms of topics and solutions to provide our customers. I have googled it a lot with still no solution. Was simple wondering if others had hit this, especially Olaf... as he has been spot on for so many of our Fox and non-Fox answers. I maybe should have pmed him, but then others would not learn this solution.

2nd sentence in original post... >>I know there are probably better places to post this, but I also know that the guys here are extremely smart too and probably has the answer.

Thanks,
Stanley


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top