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 in WinXP
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. An error will pop up, ‘0x80070005 Access denied’, click OK on the error and it goes away. Then check ‘run only if logged in’ on the Task Tab and the ‘0x80070005 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.

To Schedule a Task in Vista
1. Open Task Scheduler by clicking the Start button Picture of the Start button, clicking Control Panel, clicking System and Maintenance, clicking Administrative Tools, and then double-clicking Task Scheduler.‌ Administrator permission required. If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
2. Click the Action menu, and then click Create Basic Task.
3. Type a name for the task and an optional description, and then click Next.
4. You need to schedule based on the calendar, for Task Trigger, click Daily, and Recur every 1 days (don’t worry you will change this to minutes later).
5. To schedule a program to start automatically, for Action, click Start a program, and then click Next.
6. Click Browse to find the .vbs script that you created, and then click Next.
7. On the Summary screen, make sure to click the box for “Open the Properties dialog” before clicking on the Finish button. Click on the Triggers tab. Check “Repeat task every”, select 5 Minutes, for a duration of: 1 day. Click OK.
You can test out the task by right-clicking on the item in the list, and choose Run. The script should run silently in the background.

I have found the best way to trigger [image-webcam-overlay.php] from windows 7 is still to use Task Scheduler as you describe on your website but with the following exception:

Don’t insert [callmywebpage.vsb] under the “Edit Action” tab.

Instead insert [“C:\Program Files\Internet Explorer\iexplore.exe”] in the
Program/script box followed by
[“http://www.yourwebsite.com/image-webcam-overlay.php”]
in the Add arguments box.

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

One Response to “Scheduled HTTP Request – Windows Task Scheduler”

  1. Roy says:

    Thanks for putting your scripts in the pulic domain, I would have no hope of writing something like these. I’ve got around dozen decent weather sites bookmarked, this one sits on the top of the list. If I’m ever near Long Beach I’ll buy the beers, sorry its unlikely being just outside London UK. Cheers Mike!