Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm am wanting to know if anyone knows how to write a batch file that will check the pc to see what day it is(ex. Mon.Tues.Wed, etc.)and if it is that day then call another batch to run, but if it is not that specific day then exit. Also on the specified day once the batch file has ran the secondary batch once I don't want it to run that batch again. If anyone can help I would appreciate it.

Thomas, try something along the lines of this.
ECHO. | DATE | FIND "Fri" > nul
IF NOT ERRORLEVEL 1 CALL BATCH.BAT
If you want to delete the batch file that is called on the day, you will need to test in the calling batch file. This is because you can not delete an Open, running, file. So you would have lines like the ones above except you would DEL BATCH.BAT insted of callingit.Where as on the other hand if you want to delete the calling batch file you will have to do it from the called batch file. Same reason as above.
If you have questions email me, drscriptt@yahoo.com, and I'll try to give you more info.

Oh, yah, DOS does not have a native way to schedule tasks in the background. You will have to turn to some 3rd party, non-MS-DOS, solution. I have used Task Scheduler with much success.

Oh, well... DOS hasn't NATIVE schedulers, that's why we are meant to make them =D
This should solve your problem:
@echo off
echo. |date |find /i "FRI" > nul
if errorlevel=1 goto nottoday
if exist c:\check.dat goto end
call batch.bat
rem > c:\check.dat
goto end
:nottoday
if exist c:\check.dat del c:\check.dat
:endThat will create a temporary file c:\check.dat. Leave it alone (you can change it's location by the batch)
Any further question, letme know!
-- Secret_Doom --
secret_doom@hotmail.com
secretdoom.hpg.com.brPS: There is a little chance that one day the batch doesn't call the second one. That will happen only if you boot once in friday, don't boot for the whole week and then do only boot in the next friday.

![]() |
Pesky memory error
|
Time to FPROT your tarbal...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |