views:

357

answers:

5

I have a webpage hosted on a Windows box that I need to assure gets loaded at least once/day. My current plan is to create a scheduled task that opens Internet Explorer and hits the URL:

"C:\Program Files\Internet Explorer\iexplore.exe" myurl.com/script_to_run_daily.aspx

This was simple to setup and works fine, but it strikes me as a hack because Internet Explorer actually has to open and hit this URL. I don't need any input back from this page, it simply stores cached data in files when it's hit.

Is there a slicker way of doing this? In case it matters, this is a VB.net site.

Thanks in advance!

A: 

Use WebRequest.Create to create a new HttpWebRequest object and request the web page.

Mark Seemann
Thanks Mark, but this is a .net method, so I couldn't simply call this method directly from Windows Task scheduler could I? Are you suggesting creating a .exe with .net and calling it via the task scheduler?
Cory House
Since you asked about this on Stack Overflow I assumed you wanted a programmatic solution. If you want a tool, http://superuser.com is a better place to ask. Otherwise, you can always write a very simple executable that you can call from Task Scheduler...
Mark Seemann
...or maybe http://serverfault.com is an even better place to ask...
Mark Seemann
...or, for the non-.net version, call URLDownloadToFile(). http://msdn.microsoft.com/en-us/library/ms775123%28VS.85%29.aspx
J.J.
+3  A: 

There are Windows versions of the most common command-line http request tools, such as cURL and wget. You could certainly create a scheduled task that would run one of these. I have also done this from within a Windows Scripting Host script, if you needed to loop or create URL parameters on the fly, or some such.

JacobM
+1 for curl and wget
Andy White
+1 for many great options, I especially like the Windows Scripting Host idea, but went w/ Rick's solution since he went the extra mile w/ the complete solution. Thanks for the ideas for the future though!
Cory House
+1  A: 

You can schedule a PowerShell script. PS is pretty powerfull and gives you access to the entire .Net Framework, plus change. Here is an example:

$request = [System.Net.WebRequest]::Create("http://www.example.com")
$response = $request.GetResponse()
$response.Close()
Remus Rusanu
+5  A: 

Another option is VB Script. For example (save as file.vbs):

sSrcUrl = "http://yourdomain.com/yourfile.aspx"
sDestFolder = "C:\yourfolder\"
sImageFile = "filename.txt"
set oHTTP = WScript.CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.open "GET", sSrcUrl, False
oHTTP.send ""
set oStream = createobject("adodb.stream")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
oStream.type = adTypeBinary
oStream.open
oStream.write oHTTP.responseBody
oStream.savetofile sDestFolder & sImageFile, adSaveCreateOverWrite
set oStream = nothing
set oHTTP = nothing
WScript.Echo "Done..."
RickNZ
Ah, I should've thought of VBScript. Great idea. A +1 and an accept for you. Others had great ideas too, but you did the hard work of presenting a complete solution! Many thanks Rick!
Cory House
how will i do this in ubuntu server? alternative for vbs? java?
tony_le_montana
A: 

If the url is on internet, you can also use www.weetasks.com to call any url in 5 minutes interval.

it's free, but guys like this may start to charge $ before you know it
aron