logo

Run asp.net MVC URL in background as scheduled task using vbs and bat files

asp-net-scheduler

How to delete old files using asp.net MVC from server which are no longer in use, consider expired documents.
on my server I have documents which expires after one month. so after a month those documents are not required.
users generate more documents every day, so to keep disk space optimized it will be better to delete files which are created before one month using asp.net MVC and windows scheduler.

Step1: Create Action as below

we can run this page in browser and it will show something like the following

12 images has been deleted on 11-11-2019 12:12 PM

how to run this repeatedly and automatically once every day in background (Not in browser)

for that we need to create 2 more windows level of files

2.1: deleteimages.vbs with the following code

save this file anywhere lets say in c:/scripts/deleteimages.vbs

we can run this file using command line, but can not run using windows scheduler, so we will create a batch file to run this deleteimages.vbs file.

2.2: deleteimages.bat with the following code

save this file at same location which is in c:/scripts/deleteimages.bat

Now we can run this .bat file using windows scheduler tasks at any interval.

Google for how to run .bat file using windows scheduler.

Comments

  • This is the right webpage for anybody who would like to find
    out about this topic. You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa).
    You definitely put a fresh spin on a subject which has been written about for ages.
    Excellent stuff, just excellent!

  • Write a Reply or Comment

    Your email address will not be published. Required fields are marked *