Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :

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.

share|improve this question

migrated from Jan 17 '10 at 23:11

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

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



at 2400 25 bat2.bat


#Your code

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

share|improve this answer

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.

share|improve this answer

How To Schedule Tasks in Windows XP

From the command line: Schtasks

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.