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!
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.
As pointed out by Remus Rusanu, PowerShell would be the way to go. Here's a simple one-liner that you can use to create a scheduled task, without needing to write a separate .ps1 file:
Note that line breaks are added only for clarity in all of these command lines. Remove them before you try running the commands.
You can create the scheduled task like this: (run this from an elevated command prompt)
The above will work for PowerShell 3+. If you need something that will work with older versions, here's the one-liner:
You can create the scheduled task like this: (from an elevated command prompt)
The
schtasks
examples set up the task to run daily - consult the schtasks documentation for more options.As of PowerShell 5.0,
curl
is an alias forInvoke-WebRequest
, so you can create a Scheduled Task as follows:You can also use
Invoke-WebRequest
, butcurl
is more concise.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:
tried with curl on PowerShell 4.0, curl is an alias for Invoke-WebRequest, so you can create a Scheduled Task as follows:
Action: Start a program Program/script: powershell Add arguments: curl http://www.example.com/foo/bar
worked like a charm!
Another option is VB Script. For example (save as file.vbs):