mike1981 Posted September 6, 2006 Report Share Posted September 6, 2006 Hello All, I was wondering is it possible to create a batch file which can be placed in my start folder to open up a document (in this case a time sheet) every friday when I log into my computer?I read some guides which show the if-then construct but I was wondering how to reference the system date or day.Can anyone with some knowledge of batch files let me know if this is possible. CheersMike Quote Link to comment Share on other sites More sharing options...
Scarecrow Man Posted September 6, 2006 Report Share Posted September 6, 2006 I am not sure that feature is available. I do know, that placing an item in your startup will make it run everytime you log onto the computer.Perhaps you can put an argument into the batch file to check the date, and if it is not friday, end.like:If date = fridayendelse... rest of the codeI don't know how this would be written in code, but you can always check Microsoft's Documentation. Computer Hope also has excellent Batch file resources Quote Link to comment Share on other sites More sharing options...
mike1981 Posted September 6, 2006 Author Report Share Posted September 6, 2006 I am not sure that feature is available. I do know, that placing an item in your startup will make it run everytime you log onto the computer.Perhaps you can put an argument into the batch file to check the date, and if it is not friday, end.like:If date = fridayendelse... rest of the codeI don't know how this would be written in code, but you can always check Microsoft's Documentation. Computer Hope also has excellent Batch file resourcesHi, Thanks for the reply. You see I only want to place the batch file in the start-up folder and if the boolean value returns false then nothing opens up. the syntax you used is just about what I require but I don't think the system knows that friday actually means friday, its just a string to the system, I was hoping to find out if you could use the date as variable somehow. I will check the links. CheersMIke Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted September 7, 2006 Report Share Posted September 7, 2006 No, the system does not know if today is Friday or not. However, the system knows today's date, and you will just have to find if that date happens to be a Friday.DOS commands are not that sophisticated, but you may call a VBS script that uses the Weekday() function to find what day-of-the-week a certain date is. See this guide for VBScript and JScript documentation. Quote Link to comment Share on other sites More sharing options...
cozofdeath Posted September 7, 2006 Report Share Posted September 7, 2006 Of hand I can think of "date /T | find "Fri" then I think you could use an IF errorlevel but I'll look around to make sure. Quote Link to comment Share on other sites More sharing options...
cozofdeath Posted September 7, 2006 Report Share Posted September 7, 2006 K, after diggin though the for command I came up with this and it seems to work good on my computer.@for /F "tokens=1" %%i in ('DATE /T') do @echo %%i@if %today%==Fri (@start C:\docume~1\owner\spreedsheet.xls") else (exit)It filters out the day from the DATE /T command then echos it to the screen and IF its FRIday then open the spreedsheet, if not exit the command prompt. You can loose the first echo, I just used it to see if everything was going right when I was messing with this. You may see the command prompt popup quick when you computer starts but it has to to run the batch file. A simpler option would be to schedule a task. Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted September 8, 2006 Report Share Posted September 8, 2006 What do you get if you issue DATE /T from the command prompt? The result may depend on your date format definition. I only get 2006/09/08 - there is no day-of-the-week in it.So the O.P. may still have to use VBScript; in fact the whole thing could be written in VBScript. Quote Link to comment Share on other sites More sharing options...
cozofdeath Posted September 8, 2006 Report Share Posted September 8, 2006 Your right Pat. I honestly never knew there was a difference. You shot me down after I spent all that time looking at that disgusting FOR command. lol I did find this site that tells why the date is different per country code and it also gives some good examples on getting the date. Also, vbs in my opinion would always be better then a batch file, however, I'm in no way going to attempt to write a vb script.Hey ain't you a vb person?? *hint hint Quote Link to comment Share on other sites More sharing options...
ɹəuəllıʍ ʇɐb Posted September 8, 2006 Report Share Posted September 8, 2006 I am happy that you learnt to use the distinguished FOR command... :D Regarding VBScript - I have never used it, but it sounds like an interesting and powerful scripting language.For the original poster; wouldn't it be much easier to schedule a weekly task that opens your time sheet document every Friday morning at 10:00 ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.