VBscript find open Internet Explorer window

I am running the script below through a remote scheduler. When this script runs, the script runs as user "SYSTEM". This in turn also opens Internet Explorer under the "SYSTEM" user.

Here is my problem, if I am logged on to the computer, the script does not work correctly. The script does not see the IE window if it is started by "SYSTEM" user. It only sees the IE Window if it is started by the current logged on user. I ran it manually and it worked because it starts the IE process as me and I was the one who was logged on.

Is there any way this script could see the IE Window if it is started by a user other than the one currently logged on? Thanks in advance.
set IE = createobject("internetexplorer.application")
IE.navigate "http://www.site.org"	
IE.visible = true
 
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
 
For i = 0 to objShellWindows.Count - 1
    Set objIE = objShellWindows.Item(i)
    strURL = objIE.LocationURL
    If strURL = "http://www.site.org" Then	
     'Perform Task
end if
Next

Open in new window

abgtempAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmazingTechCommented:
The script or the logged on user doesn't see IE.

Try running the scheduler in interactive mode. The easiest is to use AT to schedule the task.

AT \\RemoteComputer hh:mm /interactive cscript c:\site.vbs
0
abgtempAuthor Commented:
Thanks for the quick reply. The script doesn't see IE.  The thing is, I can actually see Internet Explorer open, but the script does not.  Run the following script manually first, then run it using the command (AT  hh:mm /interactive cscript c:\site.vbs. You can see what I am talking about.
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
 
 
Set IE = createobject("internetexplorer.application")
IE.navigate "http://www.microsoft.com"       
IE.visible = true
wscript.sleep 3000 
 
If objShellWindows.Count = 0 Then
    Wscript.Echo "No browser windows are open."
    Wscript.Quit
End If
 
blnFound = False
 
For i = 0 to objShellWindows.Count - 1
    Set objIE = objShellWindows.Item(i)
    strURL = objIE.LocationURL
    If InStr(strURL, "http://www.microsoft.com")Then
        blnFound = True
    End If
Next
 
If blnFound Then
    Wscript.Echo "At least one browser window is open."
Else
    Wscript.Echo "No browser windows are open."
End If

Open in new window

0
abgtempAuthor Commented:
That probably wasn't the best way to test this. The only way I could simulate this error was creating another user on my computer. Then using the RUNAS command, start the the script as that other user. The script does not see the IE window when it was ran as a user other than the one logged on.  
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

AmazingTechCommented:
Try this instead.

runas /user:administrator "wscript c:\at\ie.vbs"


at 13:00 /interactive cscript C:\at\ie.vbs
Set objShell = CreateObject("Shell.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\test.txt")
 
 
 
Set IE = createobject("internetexplorer.application")
IE.navigate "http://www.microsoft.com"
IE.visible = true
 
do while ie.busy
   wscript.sleep 1000
loop
 
 
Wscript.Echo ie.locationurl
f1.writeline ie.locationurl
 
IE.navigate "http://www.cnn.com"
 
do while ie.busy
   wscript.sleep 1000
loop
 
 
Wscript.Echo ie.locationurl
f1.writeline ie.locationurl
 
f1.close

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abgtempAuthor Commented:
Thanks for the help.  Could you also give me some assistance on another open question that I have.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23874454.html
0
AmazingTechCommented:
Did one of these solutions work for you here? If it did can you select which one and close this question if it has been answered.

I'll take a look at your other question.
0
abgtempAuthor Commented:
Thanks for the help. I'm bumping up the points for the quick response
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.