1.

Solve : Detect time in batch file?

Answer»

i need my batch file detect time....

like this:---> if the time 16:45 and above goto shutdown...........
                    if not goto first

can somebody help me.......??there are two METHODS you could use,
the AT method that would add a scheduled time and command:
Code: [Select]AT 16:45 "c:\path to batch\shutdown.bat"
shutdown.bat:
Code: [Select]shutdown -s -t 30

orrr.
you can check time and all using the FOR loop:
Code: [Select]echo off
for /f "tokens=1-3 delims=:." %%a in ("%time%") do set newtime=%%a%%b
if %newtime% GEQ 1642 goto shutdown
goto first
pause

:shutdown
shutdown -s -t 10
exit

:first
rem commands

the script will interpret %time% into a 4 digit number with no .'s

then if the %newtime% (1642) is greater than or equals to 1642 goto shutdown
or goto first
that is not what i want......
ok let me explain clearly
if using AT command it just run when time is correctly punctual...
but now i want to run the second batch file even after time 16:45 which mean 16:46, 16:47, 16:48, 16:49 and on
so then you wouldn't need to use the at command if you use the batchEasy...

echo off
:start
commands
for /f "tokens=2 delims=: " %%a in ("%time%") do if %%a%%b gtr 1645 (goto shut) else (goto start)
:shut
shutdown -s -t 01

That should work...as long as its in 24h format. Quote from: Helpmeh on June 13, 2009, 02:52:30 PM

Easy...

echo off
:start
commands
for /f "tokens=2 delims=: " %%a in ("%time%") do if %%a%%b gtr 1645 (goto shut) else (goto start)
:shut
shutdown -s -t 01

That should work...as long as its in 24h format.

helpmeh, theres one flaw in the script
Quote
for /f "tokens=2 delims=: " %%a in ("%time%") do if %%a%%b gtr 1645 (goto shut) else (goto start)

tokens should equal 1-2 because it will only turn out as:
(minutes)%%btotally missed that...writing on a dsi is hard.psp isn't a walk in the PARK either  Quote from: BatchFileBasics on June 14, 2009, 11:30:16 AM
psp isn't a walk in the park either 
Too true...although DSi Internet uses the touch screen for typing, loading the keyboard takes a lot of time, as does everything...it also has a 700 something by 800 something resolution...and it uses opera, which I have never used previously.yea.
i am using opera right now. very fast to start up cold and all.
its pretty fast too. doesn't burn your CPU down(well mine anyway). Quote from: BatchFileBasics on June 14, 2009, 12:09:55 PM
yea.
i am using opera right now. very fast to start up cold and all.
its pretty fast too. doesn't burn your cpu down(well mine anyway).
Other than opening the keyboard, it's fairly fast...yea,
and seeing from other posts, you really love telling people.

Quote
that should do it...I had to MAKE that on my dsi so I had to write everything, no copypasta.

Quote
btw, I can't test it as I am STILL on my DSi

Quote from: BatchFileBasics on June 14, 2009, 12:28:32 PM
yea,
and seeing from other posts, you really love telling people.


I'm excited is all...I got it for my confirmation (along with $250), so I've been GOING crazy!i know how you feel. when i first got my psp. myspace was so fun haha.

"hey whats up, i just got my psp and im writing right now!!!!"

"hey guys guess what, im writing on my psp"

hahaI see you guys are working hard on Fareast187's problem.


Discussion

No Comment Found