0

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

Community
  • 1
  • 1
user1862341
  • 171
  • 1
  • 9
  • 1
    You can't. VBS uses IDispatch not type libraries. `MyObj = CreateObject("xshell.ScriptHost")`. – Noodles Apr 14 '19 at 19:56
  • MyObj = CreateObject("xshell.ScriptHost") will throw error 800A01AD – user1862341 Apr 15 '19 at 02:47
  • is there a way to walk around this ? how could i using xshell object in vbscript – user1862341 Apr 15 '19 at 06:09
  • @user1862341 what that is showing you is the [Registrar Script](https://learn.microsoft.com/en-us/cpp/atl/creating-registrar-scripts?view=vs-2019) built into the executable. If those classes are being registered then they should exist in the Windows Registry. – user692942 Apr 18 '19 at 23:06
  • from register script we can see it do force removement some class , so the class not registe in the windows registry, if i can change the register script by myself maybe i can register the class what i need , such as "Xshell.ScriptHost" – user1862341 Apr 19 '19 at 10:00

1 Answers1

2

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.


user692942
  • 16,398
  • 7
  • 76
  • 175
  • i try to use regedit to search progID of Xshell but failed , is there any other way to use xshell lib in vbscript ? – user1862341 Apr 16 '19 at 05:06
  • what is the mechanism of vba reference xshell.tlb and using xshell lib ? – user1862341 Apr 16 '19 at 05:08
  • @user1862341 If you have searched the `HKEY_CLASSES_ROOT` for both 32 and 64 bit for `xshell` across keys and values and still find nothing, then I'm afraid you are out of luck. Late binding in VBScript requires a registered ProgID unlike VBA which can use both Early and Late binding. From the [limited documentation](https://netsarang.atlassian.net/wiki/spaces/ENSUP/pages/135136520/Script+API) I can find it looks as though it is designed to run from inside XShell and isn't exposed, all examples refer to the `xsh` but never show its instantiation so its likely controled by the app at runtime. – user692942 Apr 16 '19 at 06:31