user3751964
user3751964

Reputation: 5

How to find out whether a webpage is opened or not using VBScript

I tried with this below code to find out whether the webpage is opened or not, but this code is not working for me. System is just flashing only the first opened webpage URL.

surl ="http://www.google.com/"
set shapp=createobject("shell.application")
For Each owin In shapp.Windows
  msgbox owin.document.location.href
  if Instr(1,owin.document.location.href,surl)>0 then
    msgbox "Window opened"
  end if
Next
set shapp=Nothing

The error message is:

Script execution time was exceeded on script "D:\ie_open.vbs" Script execution was terminated

Upvotes: 0

Views: 764

Answers (2)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

Given the error message "Script execution time was exceeded ...", the problem may be caused by a too small time out. See here. Use something like:

cscript //T:0 "D:\ie_open.vbs"

to test this assumption.

A default timeout value can be stored in the registry in either of the following locations:

  • HKCU\Software\Microsoft\Windows Script Host\Settings (per user)
  • HKLM\Software\Microsoft\Windows Script Host\Settings (global)

Deleting the Timeout value removes the preset timeout.

Upvotes: 2

MC ND
MC ND

Reputation: 70923

Instead of owin.document.location.href Use oWin.locationURL

Upvotes: 0

Related Questions