23/06/09

How to execute schedule a task to run aspx page

source:
http://www.aspnetcafe.com/post/2007/12/Scheduled-task-in-middle-trust-enviroment.aspx


Create a vbs file with the creation of a xmlthttp request:

Call RunIt()

Sub RunIt()

'Let the script to finish on an error.
On Error Resume Next

'Declare variables
Dim RequestObj
Dim URL

Set RequestObj = CreateObject("Microsoft.XMLHTTP")

'Request URL...
URL = "http://www.URL.com/jobsendmail/default.aspx"

'Open the HTTP request and pass the URL to the objRequest object
RequestObj.open "POST", URL , false

'Send the HTML Request
RequestObj.Send

'Set the object to nothing
Set RequestObj = Nothing

End Sub
'End of file

Get the directory of the vbs on the server using aspx page:

Response.Write(Server.MapPath("schedule.vbs"))



On the scheduler task use the path returned and define the schedule to run

Simple and easy