Link to home
Start Free TrialLog in
Avatar of NEARNG
NEARNGFlag for United States of America

asked on

get day of week in dos batch file???

Users on my network have a logon script called LOGON.BAT

I want to perform specific processing based upon day of the week.  Basically if the day of the week is Tuesday, Thursday, Saturday, or Sunday I want some specific processing to take place.  If not, just exist.

How can I code my LOGON.BAT file to check for those specific days????
Avatar of brianadkins
brianadkins
Flag of United States of America image

for /f %%a in ('date /t') do set DAY=%%a

then just check for specific values, I.e.:

if %DAY%=Fri goto :skipprocessing
forgot the double equal sign as a comparator:

----------------8<-------------------------------
for /f %%a in ('date /t') do set DAY=%%a

if %DAY%==Mon goto :skipprocessing
if %DAY%==Wed goto :skipprocessing
if %DAY%==Fri goto :skipprocessing

:: put your processing here

:skipprocessing
----------------8<-------------------------------
Avatar of NEARNG

ASKER

That worked!!!!  Thanks Brian!

Can I ask you one more question related to this??  I have increased the point value for your efforts.

Desktops on my network all have characters 12 and 13, of their computer name, as WK.

Laptops have an NB for characters 12 and 13.  So, my laptop is ABAB-98989-NBL1.  

What I want is for all laptops to perform the processing no matter what day it is.  This is because laptops "touch" the network at infrequent times.  So, if characters 12 and 13 of the computer name equal to NB...  Perform processing every day.

Desktops can "skipprocessing" on Mon, Wed, and Fri.

Can you help??

Thanks!!!!!!!

Eric
ASKER CERTIFIED SOLUTION
Avatar of brianadkins
brianadkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But if I want for every day to run a different process, is this possible? Thank you