Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

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

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

3 Answers 3

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.

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

 
discard

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