[util] Check COM Object by ProgID
Extended a utility VBS from Hairy-Spider blog which checks if it can create a COM object. Added listing of COM Object Description, Current Version, and File Path to DLL / EXE if it can get it.
Not rocket science. Not even rocks and sticks, but... I've written the CreateObject(ProgID) VBS files a bazillion times so I figure I might as well trick it out a bit and pass it around. I'm sure there are weird cases this won't work for, but it's passed my 5 excruciating tests.
+ VBScript Code
dim zpProgID, opObj, state
zpProgID=""
state = vbOK
while state=vbOK
zpProgID = InputBox("Please enter the ProgID","ProgID Request", zpProgID)
if zpProgID <> "" then
err.Clear
on error resume next
set opObj = CreateObject(zpProgID)
if err.number<>0 then
state = MsgBox("Object creation failed: " & vbNewLine & err.Description & vbNewLine & "Try Again?", vbOKCancel)
else
Message = ""
CLSID = ""
CurrentVersion = ""
Description = ""
Message = "Object creation successful: " & zpProgID
Set WSHShell = CreateObject("WScript.Shell")
Description = WSHShell.RegRead("HKCR\" & zpProgID & "\")
If Description <> "" Then
Message = Message & vbNewLine & "Description: " &Description
End If
Message = Message & vbNewLine
CurrentVersion = WSHShell.RegRead("HKCR\" & zpProgID & "\CurVer\")
If CUrrentVersion <> "" Then
Message = Message & vbNewLine & "Current Version ProgID: " & CurrentVersion
CLSID = WSHShell.RegRead("HKCR\" & CurrentVersion & "\CLSID\")
Else
CLSID = WSHShell.RegRead("HKCR\" & zpProgID & "\CLSID\")
End If
If CLSID <> "" Then
InProcServer = WSHShell.RegRead("HKCR\CLSID\" & CLSID & "\InProcServer32\")
Message = Message & vbNewLine & InProcServer
End If
state = MsgBox(Message & vbNewLine & "Try again?", vbOKCancel)
end if
else
state = vbCancel
end if
wend