Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Problem with InternetExplorer in ShellWindows


Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2008, 11:52 AM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default Problem with InternetExplorer in ShellWindows


I have put together a program for my company that keeps an eye on internet explorer windows. The program is designed to block sites that my boss does not want salespeople using.

So far all the code works fine, but here is the problem. It only works for internet explorer windows that were already running prior to my program starting up. For instance if I start my program first, and then start internet explorer, it doesn't work.

I am using the following code inside of a timer

For each IE as InternetExplorer in New ShellWindows

Next

For some reason it doesnt want to recognize new internet explorer windows, only ones that are already loaded. I'm sure this is a simple problem that has a simple solution but I can't figure it out.

Currenty using Internet Explorer 7, programming in Visual Studio 2008

Last edited by Guitarmonster; 02-13-2008 at 12:06 PM.
Reply With Quote
  #2  
Old 02-13-2008, 12:48 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

I think i figured it out. I read something about if "launch internet explorer windows is a separate process is enabled" it won't work. So i used a registry hack to manually disable it. Now it picks up ie regardless of when it was executed. Although it resolves the issue now, i'm starting to realize that i'm not using the best technique for controlling ie. If anyone has any better ideas please post them here.
Reply With Quote
  #3  
Old 02-13-2008, 01:01 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

yeah this definetely is not working out. When I open internet explorer the program works, when I open a new ie window the program doesn't do anything with the next window. Looks like I need to completely scrap what I have and start new with something totally different.
Reply With Quote
  #4  
Old 02-13-2008, 01:03 PM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

Quote:
Originally Posted by Guitarmonster View Post
If anyone has any better ideas please post them here.
Tell your boss to buy a software package that handles this.
Reply With Quote
  #5  
Old 02-13-2008, 01:22 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

why would he do that when he has a programmer? I've already written the program, it does exactly what he wants, restricts access during working hours. My program allows him to set lunchtimes for his employees, so they can have unrestricted access during lunch. As well as other integration features that I haven't mentioned here.
Reply With Quote
  #6  
Old 02-13-2008, 01:40 PM
AstroTux's Avatar
AstroTux AstroTux is offline
Junior Contributor
 
Join Date: Aug 2007
Posts: 345
Default

Look over your code. What is it doing at initialization that means it sees any windows at all? Could you effectively re-initialize the window list in your app, or doesn't that work? Obviously it would need to refresh the list maybe every 5 seconds or something.

Best regards,
AstroTux.
Reply With Quote
  #7  
Old 02-13-2008, 02:25 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

I have tried 2 methods

the first method:

Code:
Imports SHDocVw
Imports MSHTML

Public Class Scanner
    Dim SWs As New SHDocVw.ShellWindows

Public Sub ScanIEWindows()
For Each IE As InternetExplorer In SWs
         'Code that handles screening the urls
Next
The second method:
Code:
Imports SHDocVw
Imports MSHTML

Public Class Scanner

Public Sub ScanIEWindows()
For Each IE As InternetExplorer In New ShellWindows
         'Code that handles screening the urls
Next
Both methods give me the same results. Now you would think that method 2 would "refresh" the list since every time the ScanIEWindows sub is called, it is declaring "New ShellWindows", meaning that it is new at that point. Then destroying it after the sub is done executing, but that's not the case. I have a feeling that both of these methods are just not working since xp is designed to launch internet explorer in a new process if you have over a certain amount of ram.

My other option is, I might just create an instance of internet explorer from my program, and remove any shortcuts from the start menu, that way my program has control over it completely. But I would rather figure out how to control any ie window regardless of how it was executed. Our salespeople are not as dumb as they look.
Reply With Quote
  #8  
Old 02-13-2008, 02:57 PM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,505
Default

Have you protected against the following trivial attacks on this software package?
  • Kill the application from task manager.
  • Edit the startup entries so this program does not run.
  • Use Firefox (can be run from a thumb drive, "they can't install software" is not a solution).
  • Use Opera.
These are just the unsophisticated ways to stop it.

The fact is, even if your boss has a programmer, has he considered the cost of having you develop this, then maintain it as people find new ways around it? Net Nanny costs $40. You've spent at least four hours today on it, and probably four hours yesterday on it. Even if you are making minimum wage, you're costing one license per day you work on this ineffective software.

You could block sites at the network hardware. This is tough to defeat for the average user, since no matter what software they use it has to go through the network hardware. Of course, proxies, tunnels, and vpns can go right through this.

The most reliable way to restrict employee usage is to make a policy clear that visiting certain sites won't be tolerated. Then, when someone is caught visiting that site, have all their things in a box for them the next morning. People learn fast when their buds can't go to lunch with them because they're too busy finding a job.
Reply With Quote
  #9  
Old 02-13-2008, 03:04 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

This is what they want to do, there are other features that have already been integrated into the program, and they do not want to dispose of it.

Not only that, but as a programmer I want to figure this out, that's what these forums are for, we all like to figure things out, that's why we all decided to program.

Back to the problem, when you open a new tab in tabbed browsing in ie, that also is not able to be looked at with the .net code. I feel that there is a very simple solution to this because I read all over the net that people are using the same code to control multiple ie windows without any problem whatsoever. I just want to figure this out, I don't want to buy another program, I want to code.
Reply With Quote
  #10  
Old 02-13-2008, 03:12 PM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,505
Default

I tried this in a console application and I am having no troubles:
Code:
Imports SHDocVw
Imports MSHTML

Module Module1

    Sub Main()
        ScanIEWindows()

        Threading.Thread.Sleep(10000)

        ScanIEWindows()
        Console.ReadLine()
    End Sub




    Public Sub ScanIEWindows()
        Dim windows As New SHDocVw.ShellWindows()

        For Each window As SHDocVw.InternetExplorer In windows
            Console.WriteLine(window.LocationURL)
        Next
    End Sub
End Module
Also, I tested it with tabs and it's working just fine. I opened a window, started the program, then while it was sleeping opened some more tabs. Everything was printed with no problems.
Reply With Quote
  #11  
Old 02-13-2008, 04:57 PM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

Looks like your on to something, your code says:

For Each window As SHDocVw.InternetExplorer

where mine says:

For Each is as InternetExplorer

it looks like since your saying "window" instead of "InternetExplorer", your left with more options than me. I'm going to try this.
Reply With Quote
  #12  
Old 02-13-2008, 06:06 PM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

Quote:
Originally Posted by Guitarmonster View Post
why would he do that when he has a programmer? I've already written the program, it does exactly what he wants, restricts access during working hours. My program allows him to set lunchtimes for his employees, so they can have unrestricted access during lunch. As well as other integration features that I haven't mentioned here.
Then why are you posting here?
Reply With Quote
  #13  
Old 02-14-2008, 07:22 AM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

It's working now, regardless of how or when ie is started up, or how many tabs, my program now has full control over browsing.

And yes, I am also implementing safeguards to protect against shutting down the program in the software. On top of that, everyone who works here understands that attempting to alter the way the systems will result in immediate termination and possibly prosecution, they make pretty good money and I doubt they will roll the dice on their 40k a year salaries, pension, and profit sharing.

Thank you for your help.
Reply With Quote
  #14  
Old 02-14-2008, 07:45 AM
Guitarmonster Guitarmonster is offline
Privileges Suspended
 
Join Date: Feb 2006
Posts: 36
Default

Here's the cool part about killing the program with the task manager. My program also actively watches the process list, if it sees the task manager it kills it and then pops up a password dialog, where a manager or IT staff can enter their password, then the program will allow the task manager. As far as startup, were hiding it in the registry, which also is restricted by my program. I'm sure there are other ways to shut it down but once again, it will take some work and im sure that these people won't want to risk their careers. And if you are going to tamper with the program you better do it fast because we have managers walking the floor constantly.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->