Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Creating a batch file which can open document on certain day

Sep 7, 2006 12:27AM PDT

Hello,

I want to write a small batch file to open certain documents on my computer when I log on, that quite easy a certain document only needs to be open on fridays so I need to find a way of checking the system date and then using something like. I asked elsewhere but didnt get much help, a guy said something about using a VBscript although I have no experience in VB, and little in batch file scripting.

if date ==friday
then open myfile.doc
else
end

Can anyone give me some help with this?

I am using XP BTW.

Cheers

Mike

EDIT: I plan to put the .BAT file in my start folder and hope to run a check daily to see if day == friday.

Discussion is locked

- Collapse -
Hint
Sep 7, 2006 12:36AM PDT
- Collapse -
Cheers
Sep 7, 2006 1:25AM PDT

Thanks for the info, I was thinking though...I need to work with the date as a sring such as "Friday" but I think I can only get a numeric value from DOS.

Do you know this to be true? or..do you think what i am trying to do is possible another way?

thanks again

Mike

- Collapse -
Very odd. Why must it be Friday?
Sep 7, 2006 1:33AM PDT

That's a new requirement. Please explain in detail why the dayofweek test must be for friday and not the number of the day of the week.

Bob

- Collapse -
reply to Bob
Sep 7, 2006 1:40AM PDT

Well I want to say something like:

if %DAY% == friday
then START myfile.doc
ELSE
END

if I have a numeric date then that value will change, for instance tomorrow is 08/.. next week 15/.. etc, when the month changes the pattern does too, some months have 31 some 28 and some 30. How would I reference an ever changing number value with only a bash script?

Mike

- Collapse -
Ahh, consider this...
Sep 7, 2006 4:12AM PDT

The DAYOFWEEK is from 0 to 6 or 1 to 7, not the day of the month.

Tell me why it must be Friday and not the number again.

Bob

- Collapse -
Huh? Let's look at some examples...
Sep 7, 2006 6:10AM PDT
Link to Guide showing that there is a "vbFriday" constant with a value of 6 as it is the 6th day of the week. Now in the script you should be able to get the Date and then get the day of week value out of it.

Get Date link

Weekday function

So why not combine those 2 functions and see if the value is 6? It may help to run some examples as I think you may not understand how various Date functions work since while the date is a number there are several numbers in it, day of the week, month and year being just a few elements.

Regards,
JB
- Collapse -
Ok i know this is old but
Nov 10, 2010 3:59AM PST

The links provided no longer work =(
How can i select the Current Day (11102010) instead of Wednesday?

Hope someone can read this soon xD

thanks!