Skip to main content.
« Blog Index

Scheduled HTTP Request - Windows Task Scheduler

This script can be used by Windows Task Scheduler to make a HTTP request to a web page on a timed basis. (I.E. every 5 minutes).

Suggested use: Scheduled updates for web cam image overlay, or Web Cam Image Uploader

Cons: Your PC needs to be constantly on and online for this to work.

Put the code below into a VBS script file called ‘callmywebpage.vbs’ (be sure to set the correct URL in the code first), save somewhere you can remember like Desktop or My Documents, etc.:

'begin VBS script code: 

Call LogEntry()

Sub LogEntry()

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

'Declare variables
Dim objRequest
Dim URL

'The URL link.
URL = "http://www.yourwebsite.com/image-webcam-overlay.php"

Set objRequest = CreateObject("Microsoft.XMLHTTP")

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

'Send the HTML Request
objRequest.Send

'Set the object to nothing
Set objRequest = Nothing

End Sub

'end VBS script code

Next: schedule the task on a timed basis (I.E. every 5 minutes)…

—————————
Scheduling Scripts with the Windows Task Scheduler:
—————————

To schedule a task (these instructions are for WinXP, Vista may be different)
On the Windows task bar, click Start, point to Programs, point to Accessories, point to System Tools, then click Scheduled Tasks, Double-click Add Scheduled Task. The Scheduled Task Wizard appears. Click Next , then click Browse. The Select Program to Schedule dialog appears. Navigate to the script that you created, click it, then Open. You are returned to the Scheduled Task Wizard.

Provide a name for the task, or keep the default, which is the filename, specify how often to run the script, click Daily, then click Next. Leave the start time and date default, click Every, then select 1 Days (don’t worry we will change this to minutes later), then click Next.

Type the user name and password for the windows logon account that will run the script,
(if you do not use a windows password: leave it blank) check the box to Open advanced properties, then click Finish.
(if you do not use a windows password: click OK on the error you will get: ‘0×80070005 Access denied’)

(if you do not use a windows password: check ‘run only if logged in’ and the ‘0×80070005 Access denied’ error will not come back.)
Click the Schedule tab, and then click Advanced. Click the Repeat task check box to select it, and then specify Every 5 minutes, specify Duration 24 hours. Click OK, and then click OK again.

Note: you may have to “Run” your task the first time to get it going. right click your task, select Run.

If you want to edit the task again: On the Windows task bar, click Start, point to Programs, point to Accessories, point to System Tools, then click Scheduled Tasks.. right click your task, select properties.

More Info …
How to schedule a task using Windows Task Scheduler
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569&sd=tech

HOW TO: Modify a Scheduled Task to Repeat By Minutes or Hours
http://support.microsoft.com/kb/226795

Leave a Reply