Computing.Net > Forums > Programming > Net Time Minus Time

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Net Time Minus Time

Reply to Message Icon

Name: JRComp
Date: October 14, 2009 at 11:43:34 Pacific
OS: Windows XP Pro
CPU/Ram: 2.0ghz/1 gig
Product: Lenovo/ibm / Thinkcentret
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: gtaion
Date: October 14, 2009 at 13:11:40 Pacific
Reply:

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=


0

Response Number 2
Name: nbrane
Date: October 15, 2009 at 20:25:08 Pacific
Reply:

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?
(sorry).


0

Response Number 3
Name: Razor2.3
Date: October 16, 2009 at 05:23:55 Pacific
Reply:

nbrane: wh(ine)ot put same code into batch script?
'Cause MS abandoned CMD in favor of PowerShell.


0

Response Number 4
Name: klint
Date: October 16, 2009 at 06:21:30 Pacific
Reply:

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


0

Response Number 5
Name: Razor2.3
Date: October 16, 2009 at 07:15:55 Pacific
Reply:

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.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Net Time Minus Time

clear Palm cache with .NET www.computing.net/answers/programming/clear-palm-cache-with-net/13409.html

ADO.Net MSDE connection problems www.computing.net/answers/programming/adonet-msde-connection-problems/13937.html

i m in trouble!! help! www.computing.net/answers/programming/i-m-in-trouble-help/8878.html