To read the article online, visit

Scheduling the Execution of an ASP Script

One question I have heard asked frequently is, "How do I schedule the execution of a certain ASP script?" Scheduling an ASP script really doesn't make sense, if you stop and think about it. If you need to schedule an ASP event, chances are the script does some type of maintenance. Perhaps it cleans up a database table, or sends out a status email, or performs some other type of maintenance chore. There are more robust and suited tools to use for such tasks, such as SQL's Job Scheduler.

There may be times, though, when it's just easier to use an ASP script to accomplish some scheduled task. So, then, just how do you schedule the execution of an ASP script? One way is to write yourself a small executable that takes a URL as a command line parameter and executes the URL. So, let's say you created a small VB EXE named RunURL which used the Internet Transfer Control. You could then schedule the following command: RunURL using at (if you're using NT) or the 95/98 Event Scheduler. (If you're unfamiliar with at, it's worth checking out. It's a small, command line program for NT. Just open up a command window and type at -h!)

Well, that's one way you could do it, but not the way I am going to write about! I offer another solution, and that's to use the Windows Scripting Host (WHS). If you've not heard of the Windows Scripting Host, it is an installation that will allow Windows to run VBScripts or JScripts you write yourself. The neat thing about WHS is that it allows your scripts to communicate directly with your applications. For example, you can write a script that will interoperate with Excel, or Word, or, more importantly for us, Internet Explorer!

So, what we will do is write a tiny VBScript that kindly asks IE to execute a URL. The only downside is that you will need to have IE open (running) when you want this script to execute. :( Oh well, I still think it sure is neat. (To download the Windows Scripting Host, jump on over to

Once you have WHS installed, you can write VBScripts or JScripts using Notepad (or whatever) and run them via the command line. You've just gotta have a .vbs or .js extension for VBScripts and JScripts respectively. Now, there isn't too much documentation on using WHS on Microsoft's site. However, a useful site I've found is the win32 Scripting Homepage.

So, let's write our simple script:

'Create an instance of IE
Dim IE
Set IE = CreateObject("InternetExplorer.Application")

'Execute our URL

'Clean up...
Set IE = Nothing

It's that easy! Pretty amazing. There is that drawback of needing IE open to have the script execute properly, but, in my opinion, this is much easier than using an EXE. Why reinvent the wheel?

The last step is to schedule the execution of this script using at or the 95/98 Scheduler. Just save the above file as RunURL.vbs and have that script executed how ever often you need it to be executed. The neat thing is your website could be sitting with some web host across the world, and you could have this little script scheduled to run on your machine. When the script fired, your ASP script, half way around the world, would be run. Amazing times we live in! :)

Happy Programming!

Article Information
Article Title: Scheduling the Execution of an ASP Script
Article Author: Scott Mitchell
Published Date: Monday, July 26, 1999
Article URL:

Copyright 2019 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers