My Time Issue

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Hunterwould
Posts: 8
Joined: 02 Sep 2009 19:24

My Time Issue

#1 Post by Hunterwould » 03 Sep 2009 18:40

Alrighty, I want this batch file to be automatic. the problem code is:

Code: Select all

 set timewanted=%time%+1 

where the plus one stands for one minute I want to add...
I need this so that later it can do

Code: Select all

 at %timewanted% /interactive (commands) 

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 03 Sep 2009 19:18

Code: Select all

@echo off
for /f "tokens=1-4 delims=:. " %%a in ("%time%") do (
   set "hr=%%a"
   set /a min=100%%b %% 100 +1
   set "sec=%%c"
   set "dec=%%d"
)
set "min=0%min%"
if %min%==060 (
   set "min=00"
   set /a hr=100%hr% %% 100 +1
)
set "hr=%hr%
if /i "%hr%"=="24" set "hr=0"
::Not sure the format of time that "at" wants so you'll
::have to figure it out.
set "timewanted=%hr%:%min:~-2%:%sec%.%dec%"
set "timewanted=%hr%:%min:~-2%:%sec%"
echo.%timewanted%

Hunterwould
Posts: 8
Joined: 02 Sep 2009 19:24

#3 Post by Hunterwould » 03 Sep 2009 19:32

Thank you This was a major help in automation
:D

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#4 Post by avery_larry » 04 Sep 2009 08:25

I'm not sure what you're trying to do -- but you could just add a 1 minute delay in your script like this:


ping -n 61 -w 800 127.0.0.1 >nul 2>nul


Might be easier/better than using "at" . . .

Hunterwould
Posts: 8
Joined: 02 Sep 2009 19:24

#5 Post by Hunterwould » 08 Sep 2009 19:00

Well I Was Gonna do that but I needed to learn how to get variables anyhow so it doesn't matter the batch is made. :wink:

Post Reply