Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '-------------
  2. 'GLOBAL VARIABLE SECTION
  3. '-------------
  4. Dim currentShift
  5.  
  6. Dim shift1TimeStart
  7. shift1TimeStart = CDate("04:30:00 PM")
  8. Dim shift1TimeEnd
  9. shift1TimeEnd = CDate("04:34:59 PM")
  10. Dim shift1URL
  11. shift1URL = "www.google.com"
  12.  
  13. Dim shift2TimeStart
  14. shift2TimeStart = CDate("04:35:00 PM")
  15. Dim shift2TimeEnd
  16. shift2TimeEnd = CDate("07:59:59 AM")
  17. Dim shift2URL
  18. shift2URL = "www.ewn.co.za"
  19.  
  20. 'add more shifts by copy-pasting above and changing number in variable, e.g. shift3TimeStart, shift4TimeStart, etc
  21.  
  22. Dim tim
  23.  
  24. '-------------
  25. 'LOOP SECTION
  26. '-------------
  27.  
  28. Do
  29.  
  30.     tim = Time()
  31.  
  32.     Dim calculatedShift
  33.     Dim calculatedURL
  34.  
  35.     If (tim >= shift1TimeStart) And (tim < shift1TimeEnd) Then
  36.         calculatedShift = 1
  37.         calculatedURL = shift1URL
  38.     ElseIf (tim >= shift2TimeStart) And (tim < shift2TimeEnd) Then
  39.         calculatedShift = 2
  40.         calculatedURL = shift2URL
  41.     'rest of shifts here with else-if statements
  42.     End If
  43.  
  44.     If (currentShift <> calculatedShift) Then
  45.         currentShift = calculatedShift
  46.         KillIEProcesses
  47.         StartIE(calculatedURL)
  48.     End If
  49.    
  50.     If (IERunning <> true) Then
  51.         StartIE(calculatedURL)
  52.     End If 
  53.    
  54.     WScript.Sleep 60000
  55.  
  56. Loop
  57.  
  58. '-------------
  59. 'SUB FUNCTIONS SECTION
  60. '-------------
  61.  
  62. Function IERunning()
  63.     Dim result
  64.     result = false
  65.     Dim WMIService : Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
  66.     Dim ProcessList : Set ProcessList = WMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
  67.     Dim Process
  68.     For Each Process in ProcessList
  69.         result = true
  70.     Next
  71.     Set WMIService = Nothing
  72.     Set ProcessList = Nothing
  73.     IERunning = result
  74. End Function
  75.  
  76. Sub KillIEProcesses()
  77.     Dim WMIService : Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
  78.     Dim ProcessList : Set ProcessList = WMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
  79.  
  80.     Dim Process
  81.     For Each Process in ProcessList
  82.         Process.Terminate
  83.     Next
  84.     Set WMIService = Nothing
  85.     Set ProcessList = Nothing
  86. End Sub
  87.  
  88. Sub StartIE(strURL)
  89.     CreateObject("WScript.Shell").Run """iexplore.exe"" " & strURL
  90. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement