Enumerating ShellWindows in windows Service


I'm working on a windows service in which I need to interact with the desktop and control a browser instance. I've come across ShellWindows (from SHDocVw) in which I can enumerate sucessfully in a widows Forms Application to obtain the handle of the Intenet Explorer Browser.

The functionality I'm using is:-

   For Each window As InternetExplorer In New ShellWindows
   Next window

We need to migrate this funcitonality into a Windows service so that the processing can occur in the background and then on a given event the windows service will interact with the desktop
and then control the active Internet explorer instance.

However, when I try the code in the windows Service I get an error:-
System.IO.FileNotFoundException: The system cannot find the file specified.
   at MyService.PopBrowser.GetWindowsAndPop()

I have attempted to run the service by allowing "Allow Service to interact with desktop" in the Log On section and even using the specific account that I'm logged in on but it always gives the above error.

I know that the widows service isn't designed to cater for interacting directly with desktop processes but is there a way to make this work? It's not really an option to code any windows Form type application (i.e. such as to have a second application which will communicate with the service).

Many thanks


Many Thanks
Who is Participating?
mikesung99Connect With a Mentor Author Commented:

I've Put the Dll explicitly into system32 and tried to run it again but it gives the same result


cookreConnect With a Mentor Commented:
With no sample code, it's all a guess.

My first guess is a pathing problem.  Check the default directory and see if it's not system32.
and what's the code that throws the exception?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.