Net Time Minus Time

Lenovo/ibm / Thinkcentret
October 14, 2009 at 11:43:34
Specs: Windows XP Pro, 2.0ghz/1 gig
Right now at work I have to small servers getting their time from a larger server via batch files and scheduled task.

The batch reads:
net time \\shoptech /set /yes

I need the time on the two computers to be six minutes behind the time that they get from the larger server. Is there a command to set the system clock back a certain amount of minutes?

My name is JRComp, and I approve this message.

See More: Net Time Minus Time

Report •

October 14, 2009 at 13:11:40
So maybe add some math stuff to your batch, The following will do the sync and then subtract 6 min.

net time \\shoptech /set /yes
set /a mm=%time:~3,2%
set /a hh=%time:~0,2%
if %mm% lss 6 set /a hh=%hh%-1
if %mm% lss 6 set /a mm=%mm%+60
set /a mm=%mm%-6
if %mm% lss 10 set mm=0%mm%
if %hh% equ -1 set hh=23
time %hh%:%mm%
set mm=
set hh=

Report •

October 15, 2009 at 20:25:08
it seems like date/time addition/subtraction is VERY common theme. hint microsoft: your programmers have already done the work (vb DateDiff, DateAdd. vbscript, etc etc), wh(ine)ot put same code into batch script?

Report •

October 16, 2009 at 05:23:55
nbrane: wh(ine)ot put same code into batch script?
'Cause MS abandoned CMD in favor of PowerShell.

Report •

Related Solutions

October 16, 2009 at 06:21:30
And how popular has PowerShell been? Perhaps there's one PowerShell user for every 10 batch file users? And that's after PS has been out for about 3 years

Report •

October 16, 2009 at 07:15:55
klint: And how popular has PowerShell been?
Presumably it'll get more popular as XP systems are retired. Personally, I wish MS wouldn't "forget" to include some ActiveX scripting objects while pushing PS. (ScriptPW.Password, specifically.)

Actually, just be glad MS didn't go with their original plan, which was to remove CMD altogether and have PS be the only command line interface.

Report •

Ask Question