Okay, the title gives the basic problem, but I'll give a little more history because there may be solutions out there not requiring shdocvw.dll.
The problem in a nutshell:
I need to get the URL's of all open Explorer windows. Using ShellWindows, this is incredibly easy and is documented in a number of places on this site. Program works fine. However, as soon as I try to run the program as a schedule task or as a SQL Server Package, it fails when trying to create the ShellWindows object (429 activex can't create control). I've also tried some stuff that makes my program a "service" via some kind of proxy and set it to "use the desktop", but it still fails.
The program is a simple vb executable that launches a vb activex exe. The activex exe is what uses the shellwindows object.
First off, I have read
http://www.experts-exchange.com/Programming/Q_20887870.html?query=shellwindows&clearTAFilter=true. It sounds as if this guy came up with a solution, but I don't understand it. I ran the code he provided and got a nice messagebox with some Token ID, but I don't know what the hell a token is (other than something to ride a subway with) and I would not know how to get a hold of an Internet Explorer object using merely this token value. So there's one possible solution, if anyone can help there.
The history of what I'm actually trying to do:
There are some files out there on the internet that are in CSV format. I want a program to run nightly on one of our organization's servers, unattended. The program needs to run under its own login or under the System login. The program automates Internet Explorer and navigates to the URL of the CSV file. To bypass the download dialog, I have set the properties for CSV files in Windows to be opened in Internet Explorer by default (great trick). What happens then, however, is that a new window is spawned and the CSV file appears in the new window. Also, the URL in the Address bar is NOT the URL where the CSV file was originally, but instead shows the path to the newly downloaded CSV file in the Internet Cache. That's all and good, so long as I can figure out that path. To get that path, I use shellwindows to loop through all open windows and search for the name of the file I'm looking for within each URL (fortunately, I do know the name of the file I'm looking for). Once I get the path to the file, I can copy it to the location I really want it to be in and begin a nightly processing job.
Before I discovered the ShellWindows method, I did have an alternate method. This was to find the root of the Internet Cache and simply loop through all the files there until I found the one I need. This of course takes longer and I found that oftentimes the file I wanted was in a "locked" state and I could not copy it.
If I cannot figure out how to get this program to run unattended on a server, I will have to revert to the old method of looping through the cache, and I really don't want to do that.
The programs runs FINE when I run it directly.
I give the entire history here because the overall goal is to get these files off the internet. The vendor refuses to provide the files via ftp, so I am stuck with CSV files located on a server. so if there are any other approaches out there, please chime in.
Also, another way I could get the URL might be: since I'm already automating IE to navigate to the CSV file, one would think that I could use automation to get the URL of the new Window. However, I can't find any way using the Internet Explorer object model to find instances of new windows spawned by the original instance, especially if the new window ends up being more like a Windows Explorer window than an Internet Explorer window.
TJ
Start Free Trial