I was trying to work on a pop-up blocker.
Createobject gives you an object that you can trap the newwindow2 event, but you can't cancel it because VBScript uses variants, not an actual boolean.
getobject fails, in every permutation I tried. It won't accept a missing path, despite MSDN documentation. It did work in VBA leaving the path as a missing parameter, but it has no way of returning anything other than the first window opened, and no children windows collections. WMI won't do it either, it only returns the applications IEXPLORE.EXE, which hosts multiple windows in a single instance.
But fear not! and answer has been found, that gives you an object for each window with access to the document property within each.
Here is a short demo script.vbs
=======================================
dim objShell, objShellWindows, i
set objShell = createObject("Shell.Application"
set objShellWindows = objShell.Windows
if (not objShellWindows is nothing) then
for i = 0 to objShellWindows.count - 1
msgbox objShellWindows.Item(i).locationurl
next
end if
set objShellWindows = nothing
set objShell = nothing
'thanks to member billchris
Createobject gives you an object that you can trap the newwindow2 event, but you can't cancel it because VBScript uses variants, not an actual boolean.
getobject fails, in every permutation I tried. It won't accept a missing path, despite MSDN documentation. It did work in VBA leaving the path as a missing parameter, but it has no way of returning anything other than the first window opened, and no children windows collections. WMI won't do it either, it only returns the applications IEXPLORE.EXE, which hosts multiple windows in a single instance.
But fear not! and answer has been found, that gives you an object for each window with access to the document property within each.
Here is a short demo script.vbs
=======================================
dim objShell, objShellWindows, i
set objShell = createObject("Shell.Application"
set objShellWindows = objShell.Windows
if (not objShellWindows is nothing) then
for i = 0 to objShellWindows.count - 1
msgbox objShellWindows.Item(i).locationurl
next
end if
set objShellWindows = nothing
set objShell = nothing
'thanks to member billchris