How to Delete a file at a specified date

1

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.

Aryan_AdFreind

Posted 2010-01-17T04:49:04.187

Reputation:

Answers

1

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.

pagboy

Posted 2010-01-17T04:49:04.187

Reputation:

0

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.

vicatcu

Posted 2010-01-17T04:49:04.187

Reputation:

0

Mitch Wheat

Posted 2010-01-17T04:49:04.187

Reputation: 181