Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

ASP.NET run a website page periodically

It is sometimes required that a website page needs to be executed everyday/every minute, so as to run the background services of a website or check everyday which users have not yet paid and email them etc.
Create a task in task scheduler and create a vbs file that will execute the asp.net page:

VBS script:
dim URL, oArgs 
 
 Set oArgs = WScript.Arguments 
 
 if oArgs.Count = 0 then 
 msgbox("Error: Must supply URL") 
 wscript.quit 1 
 end if 
 
 URL = oArgs(0) 
 
 on error resume next 
 Set objXML = CreateObject("MSXML2.ServerXMLHTTP") 

 if err then 
 msgbox("Error: " & err.description) 
 wscript.quit 1 
 end if 
 
 ' Call the remote machine the request 
 objXML.open "GET", URL, False 
  
 objXML.send() 
 
 ' return the response 
 'msgbox objXML.responSetext 
 
 ' clean up 
 Set objXML = Nothing

'cscript

Configure task scheduler as follows:

Action: Start a program
Program/script: C:\WINDOWS\system32\cmd.exe
Add Arguments (optional):/C C:\inetpub\wwwroot\AlertCron.vbs C:/WebApplications/Websites/testsite/Cron.aspx

*where AlertCron.vbs is the name and location of the vbs file created above.
*where C:/WebApplications/Websites/testsite/Cron.aspx is the physical location of the file that needs to be run periodically.
*note the space between the highlighted text.

Set the trigger (in task scheduler) and you are ready to go.


This post first appeared on Networks, please read the originial post: here

Share the post

ASP.NET run a website page periodically

×

Subscribe to Networks

Get updates delivered right to your inbox!

Thank you for your subscription

×