Using Oleview.exe to find scriptable COM objects
Hello everyone ... today, I have for you, a quick posting on how to use the Oleview program to locate COM objects that are scriptable in your daily VB scripting! I'm guessing that from the few search results on Google, that not many people are aware of this, but the Windows Resource Kit tools has a handy tool that allows you to view information about the type libraries registered with the COM server on a Windows computer. First, download and install the Windows 2003 resource kit, and then navigate to the folder you installed it to. Open up the oleview executable and browse around in it for a bit if you'd like.The purpose of using this tool (at least my purpose) is to find some COM objects that I can use with VB script to do cool stuff. One particular object I came across is the Windows Media Player type library. This can be instantiated with the following code:
set playerobject = CreateObject("wmplayer.ocx")For beginners out there who are asking "How do you know to use wmplayer.ocx?" I do have an answer! Using the oleview tool, you can figure out the name of the object you would like to create an instance of. If you'd like, follow along by opening up Oleview, and navigating to Objects Classes --> Grouped by Component Category --> Automation Objects --> Windows Media Player, and click that item. In the right-hand pane of Oleview, you'll see some information about the type library, and more specifically, the ProgID (or VersionIndependentProgID) of the object. This is what you need to know in order to create an instance of a COM object. While writing this article, I decided to randomly choose another object in the same list as another example, so go ahead and navigate to Microsoft Agent Control 2.0. Again, on the right side you should see the VersionIndependentProgID of "Agent.Control". By calling the built-in VBscript function CreateObject, you can instantiate this object as well.Now, you might be asking yourself: "What can I do with this object once I've got an instance of it?" That will hopefully come in another article shortly as I'm running out of time, however, I will tell you that you can use Oleview to find out the answer for yourself. Happy scripting!
My life of learning various things about technology including network administration, development, and 3D design