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:

  1. 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.
  2. 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.
  3. 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

    addscheduledtask.jpg


  4. Click Next to start the wizard.

    2010-06-28_15.37.34.jpg


  5. Pick Internet Explorer from the applications list.

    2010-06-28_15.38.11.jpg


  6. Give the task a unique, descriptive name.

    2010-06-28_15.41.57.jpg


  7. Specify the times the task should run.

    2010-06-28_15.42.32.jpg


  8. Check Open advanced properties for this task when I click finish.

    2010-06-28_15.44.32.jpg


  9. 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.

    2010-06-28_15.45.55.jpg


  10. 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.2010-06-28_16.26.29.jpg