I want to delete a file (a .exe) from a folder, after a specified date, say 25/Feb/2010. How can I use scheduled tasks and batch files for this. I am not sure whether the code below work :

@ECHO OFF
CLS
CD c:\target_folder\
ECHO Y | DEL innocent.exe

Will it work? If not, what will?

And how to run it on or after a specified date? Another doubt is how to go about adding it to scheduled tasks? Will it work if I don't turn the system ON, on 25/FEB? My requirement is this, the file should be deleted after that date.

link|improve this question
@Aryan: this kind of question don't fit this site, as it is aimed for programming tasks. At superuser.com you are more likely to get better answers for this kind of question. Anyway, don't go there and ask it, as this very same question will most likely be migrated to that site, where the same question will appear, along with the answers so far. – voyager Jan 17 '10 at 5:05
I am sorry for violating the guidelines. While searching for the solution I saw questions of similar nature in s'flow. I never really tried to read more about the content policy. I assumed it would be OK. So, next time I will not do this. – Aryan_AdFreind Jan 17 '10 at 5:21
feedback

migrated from stackoverflow.com Jan 17 '10 at 23:11

This question came from our site for professional and enthusiast programmers.

3 Answers

http://support.microsoft.com/kb/313565

Summary: Use the at [time] [command] command.

Example:

bat1.bat:

at 2400 25 bat2.bat

bat2.bat:

#Your code

These 2 .bat files will, every month on the 25th, run bat2.bat.

link|improve this answer
feedback

If you're on a unix system read this wikipedia article about Cron. This article gives some ideas on how to get the same effect in windows. Looks like basically Start > Programs > Accessories > System Tools > Scheduled Tasks.

link|improve this answer
feedback

How To Schedule Tasks in Windows XP

From the command line: Schtasks

link|improve this answer
BTW: I think this belongs on superuser.com – Mitch Wheat Jan 17 '10 at 4:57
feedback

Your Answer

 
or
required, but never shown