1.

Solve : Batch File System Time condition...?

Answer»

I have a batch file in my Startup folder. The batch file opens an excel file that copies files. Can I add a condition in the batch file that only opens the excel file if the system TIME is between 2:00am and 4:00am. If I have to reboot the PC because it locks up, ETC., I don't want the script to run.

Thanks!

BTW, I'm only doing this way because I can't get the Windows Scheduler to execute.just an example for you to start with....

for /F "tokens=1,2 delims=: " %%i in ('time /T') do (
set hr=%%i
set min=%%j
if %hr% EQU .........
if %min% EQU ........
)

once you get the hr and min, you can do comparisons with it..
Thanks!

I see where you reference 'i' in the first line, but where do you reference 'j'?

ALSO, I assume 'EQU' is 'equal to'. Are there corresponding values for 'greater/less than'?

Thanks again!Quote

I see where you reference 'i' in the first line, but where do you reference 'j'?
because of the "tokens=1,2", %%i will get the first token, %%j will get the second token. For more information, type for /?

Quote
Also, I assume 'EQU' is 'equal to'. Are there corresponding values for 'greater/less than'?
YES, please look up help page for "if" by typing if /? on the command line.


Discussion

No Comment Found