Programming, Tips & Tricks

Execute Web Page Using Task Scheduler

Sometimes you have to create console application or window services to run based on schedule time and you just need to use Task Scheduler and set your time and it will be run automatically. It is easy to schedule console application or windows service with stand alone logic to run individually to access database or other services and do whatever logic for the iterative purpose.

Why schedule a Page?

In some cases, you have to use data layer and other dependent class library projects that might be changed and require to get the latest updated code in schedule job. In such a case you can schedule a page considering to set the URL to call that page on schedule time and the logic behind the page will be run.

To call the page in Task Scheduler, you have to use PowerShell command and pass your URL on this command as below

1. Add new action and enter “PowerShell” in Program/Script
Add_Action_techzigg

2. Add Argument
Enter following code to pass as arguments

ExecutionPolicy unrestricted -Command “(New-Object Net.WebClient).DownloadString(“http://www.techzigg.com/test.aspx”)”

Add_Argument_techzigg

Using powershell.exe you can call webclient to get your url run in scheduler just put your code in load event to execute in each request and run properly with error handling so you can track your scheduler and its logic.

To get your page to be run using PowerShell, please confirm that PowerShell is installed or not.

Leave a Reply

Your email address will not be published. Required fields are marked *