通过在Windows计划任务加载一个网址推荐方法 [英] Recommended method for loading a URL via a scheduled task on Windows
问题描述
我有托管在Windows中,我需要保证一个网页被加载至少一次/天。我目前的计划是创建一个计划任务,打开Internet Explorer,然后点击的网址:
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
这是简单的设置和工作得很好,但它给我的印象是一个黑客,因为Internet Explorer实际上已经打开并打这个网址。我不需要任何输入回程从这个页面,它只是存储在缓存文件中的数据时,它的打击。
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.
是否有这样做的一个滑头的方式?万一它的事项,这是一个VB.net站点
Is there a slicker way of doing this? In case it matters, this is a VB.net site.
在此先感谢!
推荐答案
正如刚才瑞摩斯Rusanu,PowerShell的将是一段路要走。这里有一个简单的一行,你可以用它来创建计划任务,而无需编写一个单独的.ps1文件:
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:
powershell -ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient)
.DownloadString(\"http://localhost/cron.aspx\")"
您可以创建这样的计划任务:
You can create the scheduled task like this:
schtasks /create /tn "MyAppDailyUpdate" /tr "powershell -ExecutionPolicy unrestricted
-Command \"(New-Object Net.WebClient)
.DownloadString(\\\"http://localhost/cron.aspx\\\")\"" /sc DAILY /ru System
本示例设置任务每天运行 - 咨询<一href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx">schtasks.exe对于更多的选择文档。
This example sets up the task to run daily - consult the schtasks.exe documentation for more options.
这篇关于通过在Windows计划任务加载一个网址推荐方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!