Search code examples
vbscriptcomxshell

How to reference type library in vbscript (typically with xshell library )


I want to use the xshell library in vbscript , but when I used createObject() to create object it failed, how could I create an Object from the type library provided by the Xshell application?

The xshell could be registered to system well, I guess, because I can add a reference in the excel vba project by 'tools->reference->"Xshell 1.0 Type Library", then I can use dim xshell as xshell.ScriptHost and I can find the Xshell info from the object browser.

enter image description here

I have tried oleviwer to find some information about the Xshell 1.0 Type Library, but actually I can't find the ProgID of xshell.

enter image description here enter image description here

I turn to exeScope ,and do i find something interesting enter image description here

in the right window we can see "ForceRemove {xxxx-xxxxxxxx-xxxx} = s'ScriptHost Class ....{ProgID=s'Xshell.ScriptHost.1'.... ForceRemove 'Programmable' ....}

how could i cancel the force remove ?

dim xshell 
set xshell=CreateObject("C:\Program Files (x86)\Common Files\NetSarang\XshellCore.tlb")
MsgBox "success"

run error with error code "800A01AD"

ActiveX component could not create object


Solution

  • You cannot create a COM component instance from a Type Library. The Type Library is a definition file that describes the Objects, Properties and Methods a COM Object Library supports be it using the IUnknown or IDispatch interfaces.

    It is simply a definition file and does not contain any implementation. If you want to try and use XShell using VBScript you need to locate the COM DLL associated with the application.

    If XShell is exposed to COM it will have registered a ProgID in the Windows Registry. If you can find the ProgID in the registry using tools like regedit.exe you could use the following check list to identify the DLL associated with it and use the ProgID with CreateObject() to instantiate an instance of the COM component.