문제

I wrote a batch that check days and time to execute particular actions.

For the time I use this:

for /f "tokens=1-3 delims=:" %%a in ("%time%") do if %%a geq 7 if %%a leq 18 goto email

And it works pretty good.

Now I would like to ensure we execute actions only from Monday to Friday.

I think with this sentence I can have a number by day (1 = Monday and so on...):

wmic path win32_localtime get dayofweek

Someone could help me to combine them to check time and day and do action or not?

Thanks for your help.

Regards

도움이 되었습니까?

해결책

As shown here, you could write:

@echo off  
set daysofweek=Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday  
for /F "skip=2 tokens=2-4 delims=," %%A in ('WMIC Path Win32_LocalTime Get DayOfWeek /Format:csv') do set daynumber=%%A  
for /F "tokens=%daynumber% delims=," %%B in ("%daysofweek%") do set day=%%B
echo day number %daynumber%
echo day %day%

(script copied from http://www.sysnative.com/forums/windows-tips-tricks)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top