How to set up a Windows Scheduled Task to delete a specific file every 2 weeks?

0

I need to delete a specific file every 2 weeks. The file is: C:\Logfile.txt

I thought I could use Windows Task Sceduler to do this, but there seems to be no option to create a 'Delete File' task.

Can someone help with this please?

Cheers for all help

Naz

Posted 2019-07-29T12:53:57.453

Reputation: 125

1Start deletion as a command: cmd /c del C:\Logfile.txt. Or start any script/program which performed this task. – Akina – 2019-07-29T13:05:26.140

Answers

1

As @Akina's comment states, you'll either want to use the del command directly:

cmd /c del /f /q "C:\Logfile.txt"

or via a batch file your scheduled task would point to:

@echo off

del /f /q "C:\Logfile.txt"

exit

Either way, I would likely include the /f to ignore the read-only attribute and the /q avoid a confirmation prompt - this way nothing should hang the task up.

mael'

Posted 2019-07-29T12:53:57.453

Reputation: 1 675

Brill many thanks!! – Naz – 2019-08-01T09:59:39.033