![]() |
|
|
Published: Monday, July 26, 1999 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: 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 http://msdn.microsoft.com/scripting/.) 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:
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 Happy Programming!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||