Rotating URL Script – Dashboard Display

Iv been looking for a tool that will display web pages for a period of time and then cycle through to the next page,  performing a loop for usage on large LCD TV screen at work,  this is to be used to display IT Service performance information and status reports.

I was unable to find one that did what I wanted,  bar 1, although it suffered from a problem where after a few hours Internet Explorer would start to die, and it had to be restarted.

I decided to write my own script, and so here it is.

The script iv written will do the following:

  • Launch an Internet Explorer instance
  • Force the IE Instance to full screen
  • Cycle through the pages supplied in the array for 40 seconds per page
  • Continue to loop until an hour passes , after an hour the script will tear down all IE instances, reset the object, wait 2 seconds, then relaunch a new instance,  and run for another hour before repeating the cycle.

** Note **
If you do not wish to have all Internet Explorer instances shutdown,  say if your using the machine thats running the script and have other IE Windows open , just remove  lines 40 and 41 , ie

1
2
'Clean All Other IE Processes
CleanAllIEProcs

The settings for URLs and page timing is easily modified with some basic VBScript changes,  anyone should be able to do it.  To add more URLs  just increase the array number and add the new URLArray(). Note, the array starts from 0, so 3 sites is actually 2. eg to use 5 sites:

1
2
3
4
5
6
Dim URLArray(4)
URLArray(0) = "http://somesite.com/page1.htm"
URLArray(1) = "http://somesite.com/page2.htm"
URLArray(2) = "http://somesite.com/page3.htm"
URLArray(3) = "http://somesite.com/page4.htm"
URLArray(4) = "http://somesite.com/page5.htm"

The hourly tear down should hopefully prevent internet explorer from screwing up.

The script does not need to be run from a scheduled task ,  just double click on it and it should launch,  the Wscript process will never die.

Main Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'------------------------------------------------
'---------- URL Rotator Script -------------------
'------ Written By Cheyne Wallace ---------------
'------------------------------------------------
'----------- 8th March 2010 ---------------------
'------------------------------------------------
' This script will open internet explorer, cycle through
' the URLS provided at an interval of 40 seconds per
' page.   After each hour it will shut down internet explorer
' and reopen it to clear the memory.
'------------------------------------------------

'Enter The URL Array - Starting From Zero ,  ie 4 URLS = 3
Dim URLArray(2)
URLArray(0) = "http://somesite.com/page1.htm"
URLArray(1) = "http://somesite.com/page2.htm"
URLArray(2) = "http://somesite.com/page3.htm"
 
StartTime = Now()
intTimeInterval = 40000 '40 Seconds

Dim InternetWindow
Set InternetWindow = CreateObject("InternetExplorer.Application")
	InternetWindow.FullScreen=True
	InternetWindow.Visible = True
	InternetWindow.StatusBar = 0
 
'Loop Over The Array Of URLS
For Each URL In URLArray
	InternetWindow.Navigate URL
	WScript.Sleep (intTimeInterval)
Next
 
While True
If DateDiff("h",StartTime,Now()) = 1 Then
	'Take Down Internet Explorer
	InternetWindow.Quit
	'Dispose The Object
Set InternetWindow = nothing
	'Clean All Other IE Processes
	CleanAllIEProcs
	'Wait For The Process's To Die
	WScript.Sleep (4000)
	'Recreate The Object and Bring Up The Window
Set InternetWindow = CreateObject("InternetExplorer.Application")
	InternetWindow.FullScreen=True
	InternetWindow.Visible = True
	InternetWindow.StatusBar = 0
	'Reset The Start Time
	StartTime = Now()
	'Navigate To The First Page
	InternetWindow.Navigate URLArray(0)
End If
 
	'Loop Over The Array Of URLS
For Each URL In URLArray
	InternetWindow.Navigate URL
	WScript.Sleep (intTimeInterval)
Next
 
Wend 
 
Sub CleanAllIEProcs
		Set objShell = CreateObject("Wscript.Shell")
		objShell.Run "taskkill /F /IM iexplore.exe"
End Sub

Leave a Reply