Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '-------------
- 'GLOBAL VARIABLE SECTION
- '-------------
- Dim currentShift
- Dim shift1TimeStart
- shift1TimeStart = CDate("04:30:00 PM")
- Dim shift1TimeEnd
- shift1TimeEnd = CDate("04:34:59 PM")
- Dim shift1URL
- shift1URL = "www.google.com"
- Dim shift2TimeStart
- shift2TimeStart = CDate("04:35:00 PM")
- Dim shift2TimeEnd
- shift2TimeEnd = CDate("07:59:59 AM")
- Dim shift2URL
- shift2URL = "www.ewn.co.za"
- 'add more shifts by copy-pasting above and changing number in variable, e.g. shift3TimeStart, shift4TimeStart, etc
- Dim tim
- '-------------
- 'LOOP SECTION
- '-------------
- Do
- tim = Time()
- Dim calculatedShift
- Dim calculatedURL
- If (tim >= shift1TimeStart) And (tim < shift1TimeEnd) Then
- calculatedShift = 1
- calculatedURL = shift1URL
- ElseIf (tim >= shift2TimeStart) And (tim < shift2TimeEnd) Then
- calculatedShift = 2
- calculatedURL = shift2URL
- 'rest of shifts here with else-if statements
- End If
- If (currentShift <> calculatedShift) Then
- currentShift = calculatedShift
- KillIEProcesses
- StartIE(calculatedURL)
- End If
- If (IERunning <> true) Then
- StartIE(calculatedURL)
- End If
- WScript.Sleep 60000
- Loop
- '-------------
- 'SUB FUNCTIONS SECTION
- '-------------
- Function IERunning()
- Dim result
- result = false
- Dim WMIService : Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
- Dim ProcessList : Set ProcessList = WMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
- Dim Process
- For Each Process in ProcessList
- result = true
- Next
- Set WMIService = Nothing
- Set ProcessList = Nothing
- IERunning = result
- End Function
- Sub KillIEProcesses()
- Dim WMIService : Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
- Dim ProcessList : Set ProcessList = WMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
- Dim Process
- For Each Process in ProcessList
- Process.Terminate
- Next
- Set WMIService = Nothing
- Set ProcessList = Nothing
- End Sub
- Sub StartIE(strURL)
- CreateObject("WScript.Shell").Run """iexplore.exe"" " & strURL
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement