Check day and if day = .. start file
Posted: 14 Jul 2017 04:26
Hi Guys,
I've found a nice peace of code for checking the day time here.
I've a list of a few programs that I want to start everyday. But just 1 program in that list must only start up on Monday.
the echo day of week=%day_of_week% will return the first 2 digits of the day.
Is there anything possible to do this with a IF statement ?
Thanks in advance!
I've found a nice peace of code for checking the day time here.
Code: Select all
@ECHO off
set v_day_of_week=
set v_day=
set v_month=
set v_year=
SETLOCAL ENABLEEXTENSIONS
for /f "tokens=1" %%t in ('date/t') do (
set v_day_of_week=%%t
if "%%ta" LSS "a" (set toks=1-3) else (set toks=2-4)
)
::DEBUG echo toks=%toks%
for /f "tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
::DEBUG echo first token=%%a
if "%%a" GEQ "A" (
for /f "tokens=%toks% delims=.-/ " %%i in ('date/t') do (
set '%%a'=%%i
set '%%b'=%%j
set 'yy'=%%k
)
)
)
if %'yy'% LSS 100 set 'yy'=20%'yy'%
set Today=%'yy'%-%'mm'%-%'dd'%
ENDLOCAL & SET day_of_week=%v_day_of_week% & SET v_year=%'yy'%& SET v_month=%'mm'%& SET v_day=%'dd'%
ECHO Today is Year: [%V_Year%] Month: [%V_Month%] Day: [%V_Day%]
set datestring=%V_Year%%V_Month%%V_Day%
echo %datestring%
echo day of week=%day_of_week%
:EOF
I've a list of a few programs that I want to start everyday. But just 1 program in that list must only start up on Monday.
the echo day of week=%day_of_week% will return the first 2 digits of the day.
Is there anything possible to do this with a IF statement ?
Thanks in advance!