Set up a Cron job in Windows to run an ASP script
If you are used to Linux environments, and working on a web application which needs to execute a function at regular intervals, you’d use a cron job. On Windows, you’d use a scheduled task instead. There is one part of the process that isn’t obvious, so here are the steps involved:
- Create the web page that executes the desired tasks – sending email, creating files, etc. For example, I have some ASP scripts that create RSS and iCal feeds from a proprietary database, that need to run daily. Record the URL for later.
- You will also need a domain account that can run the task, or a server account that can be used in perpetuity to run these types of tasks. I usually have a “fake” account that will never expire created for this type of thing.
- Select Start > Control Panels > Scheduled Tasks > Add a Scheduled Task
You can also get there through:
Start > Programs > Accessories > Scheduled Tasks > Add a Scheduled Task
- Click Next to start the wizard.
- Pick Internet Explorer from the applications list.
- Give the task a unique, descriptive name.
- Specify the times the task should run.
- Check Open advanced properties for this task when I click finish.
- In the Run field, after the path to Internet Explorer which will be filled in for you, type a space, followed by the URL of the webpage you created earlier. This should be a WEB path, not a FILE path.
- Enter the username and password for the domain account, then hit Next. It will show you a summary of your choices. Click Finish to complete the setup.