I have a script I run on a few users computers that automatically close all but one IE windows open to a certain website.

This is done because another program opens the window so they can check VIN information on cars that parts are being ordered for. Every order opens a new window. After a few orders, the extra windows get annoying. Believe it or not, it is just too much trouble to actually close the windows themselves...

In ie 6, my script worked perfectly. With IE 7 it doesnt work anymore.

does anybody know how I might be able to accomplish something like this for IE 7? I would love to deploy ie 7, but this is holding me back.

End If
Next
'Wscript.echo q
If q > 1 then
For i = 0 to objShellWindows.Count - 1
Set objIE = objShellWindows.Item(i)
strURL = objIE.LocationURL
If InStr(strURL, "http://website.com/")Then
Set chunk = objshellWindows.Item(i)
chunk.quit
exit for
End If
Next
i = 0
q = 0

4 Replies

So, just looking at it you have Option Explicit turned on, and you're using a variable called "rockin" for your loop. You never define this variable as > 0 so first you get an error on the Do loop and it quits. So if you put rockin in the DIM statement the loop will work now, but since you don't define it as > 0 (true) it will equal 0 (false) and the loop will exit immediately.

I can't see a time I would ever do this myself, but it was an interesting exercise. Here's my take on the script that I tested on IE7 successfully:

'Use scheduled task to start vbScript at 8am or login
'Script will run every 2 minutes for 9 hours