Automatically launch a webpage in the background and then close it after a certain time
- By Ramesh Srinivasan
- Published May 23, 2006
Q: I have a tip request I think might be useful to others. I have been looking around for a way to use Scheduled Tasks to launch a webpage in the background and then close it after a certain time. I do not have cron jobs on my website and the newsfeeds are cached for about 2 hours. The site is new so some pages may not be accessed as often and then the first person to access one of these pages if the cache has expired has to wait a little too long. I thought since I work on my pc for a good part of the day I could use Scheduled Tasks like a poor man's cron and call these pages every few hours to make sure there is always a cached copy. --Burt.
A: I've written a small script that'll do the task for you. Change the URL in the following script (opens Google.com by default) and set the wait time accordingly (60 seconds wait time) before the IE window will be closed automatically.
("InternetExplorer.Application", "IE_")
objExplorer.Navigate "http://www.google.com"
'Determines if the window is visible or not
objExplorer.Visible = 0
'Suspend the script for 1 minute
WScript.Sleep 60000
'Close the IE (instantiated) window
objExplorer.quit
Sub IE_onQuit()
Wscript.Quit
End Sub
Copy the above lines and paste the contents to Notepad. Save the file with .VBS extension (launchsite.vbs). You can then schedule this script to run at specific intervals
