i want to code in a dos script if current time >= 07:00 do something
This will be very hard becaus Cmd thinks the last 2 numbers are a trigger
I'm thinking I'm missing something in the time logic here... but as far as I can think it at this point I'd assume this should work... (changing HH:MM to be your 24hr format time)
for /f "delims=: tokens=1,2" %%a in ("%time%") do set stime=%%a:%%b
if %stime% GEQ HH:MM echo Success
Be warned: CMD will do a text comparison, so 2:01 AM will be > 12:01 PM. If you must do date/time math, pick a language that supports it, like VBScript or JScript.
What if we change to: for /f "delims=: tokens=1,2" %%a in ("%time%") do set stime=%%a%%b
if %stime% GEQ HHMM echo SuccessI assume that removing the colon from the two numbers should make it a straight number compare vs. a text compare (though I am also operating under the assumption that %time% always returns the time in 24hr format)?
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |