Free for PREMIUM members
[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now
One frequent question I see in the newsgroups is "How do I schedule a task to run in IIS? This article discusses one technique using a VBS Script and Windows Task Scheduler. Using Windows Task scheduler allows custom jobs to execute without having to stay logged into a server. You can use this technique to request web pages frequently on a timed basis. This keeps the page in-memory providing a better performance. This could also request web pages to perform other administrative tasks.
Here are steps to get started.
Write your VBS Script
Develop the webpage to process the HTTP Request
Create / Add table to database to track logging
Schedule the VBS Script
Write your VBS script
The script makes an HTTP request to a webpage on a timed basis. (I.E. every 5 minutes).
Force the script to finish on an error.
On Error Resume Next
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Put together the URL link appending the Variables.
URL = "http://www.YourDomain.com/track.aspx
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
'Send the HTML Request
'Set the object to nothing
Set objRequest = Nothing
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="tracklog.aspx.vb" Inherits="Tracklog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="form1" runat="server">
Tracklog.aspx.vb code behind
Partial Class Tracklog
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Put your code in that would process when Track.aspx is requested
Response.write(Track.aspx was called: & System.DateTime.Now())
Open in new window
We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.