To automatically drop delete a database using WindowsTask Scheduler, you can use the following steps:
- Open Task Scheduler
- Please create a new task and configure its trigger to run at a specific time/frequency as desired
- In the “Action” section, choose “Start a program” and set the program/script path to “dropDatabase.bat”.
The following bat Script I have given below:
REMOVE files backup older than N days forfiles /p "D:\Live_DBBakup" /s /m *.* /c "cmd /c Del @path" /d -number of days
Example :
REMOVE files backup older than 7 days forfiles /p "D:\Live_DBBakup" /s /m *.* /c "cmd /c Del @path" /d -7
Step01: Open Task Scheduler
Step02: Create a Schedule Task according to image
Step03: Provide a Schedule Task Name on Name Field Section –
Step04: Create Triggers for the specific task –
Step05: Create a Schedule for the new task –
Step06: Create a Action for the specific task –
Step07: Put your bat file following path location –
Step08: Provide windows server authentication for creating a schedule task –