jcunews

IeWebCheck.vbs

Jun 21st, 2019
169
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Usage: IeWebCheck [/i] {title}
  2. '
  3. '/i  Ignore case.
  4. '
  5. '"*" and "?" wildcards can be used.
  6. '
  7. 'Exit codes: 0 = Not found, 1 = Found
  8.  
  9. if wscript.arguments.count = 0 then
  10.   wscript.echo "Usage: IeWebCheck [/i] {title}" & _
  11.     vbcrlf & vbcrlf & "/i  Ignore case." & _
  12.     vbcrlf & vbcrlf & """*"" and ""?"" wildcards can be used." & _
  13.     vbcrlf & vbcrlf & "Exit codes: 0 = Not found, 1 = Found"
  14.   wscript.quit
  15. end if
  16.  
  17. set rx = new regexp
  18. rx.ignorecase = wscript.arguments.named.exists("I")
  19. s = wscript.arguments.unnamed(0)
  20. s2 = ""
  21. for i = 1 to len(s)
  22.   c = mid(s, i, 1)
  23.   select case c
  24.     case "*"
  25.       s2 = s2 & ".*?"
  26.     case "?"
  27.       s2 = s2 & "."
  28.     case "$", "(", ")", "+", ".", "[", "\", "]", "^", "{", "|", "}"
  29.       s2 = s2 & "\" & c
  30.     case else
  31.       s2 = s2 & c
  32.   end select
  33. next
  34. rx.pattern = "^" & s2 & "$"
  35.  
  36. set sa = createobject("shell.application")
  37. found = 0
  38. for each wnd in sa.windows
  39.   if wnd.name = "Internet Explorer" then
  40.     if rx.test(wnd.document.title) then
  41.       found = 1
  42.       exit for
  43.     end if
  44.   end if
  45. next
  46. wscript.quit found
RAW Paste Data