Scheduling a call to URL using windows scheduler
Posted on 3/17/2009 11:00:26 AM
in #ASP.NET 2.X
Hi /p>
/p>
I have used windows scheduler a lot of time while working with Sharepoint. Most of the time this was used to run some console application (which would work in off peak time to do some data management). But few days back, I had a requirement where by I wanted to schedule a windows scheduler to make a call to the page. The page would internally do some work on the load event./p>
/p>
But windows scheduler would not take the URL or a shortcut to the URL as a way to be scheduled. It needs an application// batch file etc to be scheduled. So I had to think of a different way to either schedule it in windows scheduler or some other way to schedule the task of calling the web page./p>
/p>
Then with some goggle and help from friend I found a simple way to schedule calling a webpage from the windows scheduler. The solution is described below./p>
/p>
First we need to create a .vbs/span> file. In the vbs file write the following code and save the file./p>
Option Explicit/p>
Dim objIEA/p>
Set objIEA = CreateObject("InternetExplorer.Application")/p>
objIEA.Navigate "http:////www.VikramLakhotia.com"/p>
objIEA.visible = true/p>
While objIEA.Busy/p>
Wend/p>
objIEA.Quit/p>
Set objIEA = Nothing/p>
/p>
The above code is opening an object of Internet explorer, opening the prescribed page and then also closing the internet explorer object./p>
/p>
Next create a batch file (.bat/span> file) to execute the vbs file. Below is the code for batch file and save the file./p>
/p>
cscript.exe "FullPath_of_the_VBS_File\IE.VBS"/p>
/p>
Now you can easily schedule the batch file which internally calls the vbs file and which calls the Provided URL with Internet Explorer object./p>
/p>
Regards/p>
|