Reputation: 593
I want to create a task to delete a file after 2 months from the current date. How can I do this?
EDIT -------
I was able to find how to create a task that runs once
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc once /sd 01/01/2003 /st 00:00
But how can I set the sd date to current date + 2 months thanks
Upvotes: 0
Views: 1162
Reputation: 11
schtasks /CREATE /SC ONCE /TN 'My App' /TR 'powershell.exe Remove-Item -Path "c:\apps\myapp.exe" -Confirm:$false -Force' /SD (get-date).AddMonths(2).ToString('MM/dd/yyyy') /ST (get-date).ToString('HH:mm')
Run this in powershell. It will "calculate" the current time and add two months. In the last few months I have googled how to do this for my project. I hope this will help you too. Its going to do this only ONCE after two months after you run this. I hope you can adjust the task as you wish from here.
Upvotes: 1