COM activation

Jan 2, 2011 at 2:16 PM

Is there a way to use COM compatible objects? I tried the syntax

var fso = new ActiveXObject('Scripting.FileSystemObject');
but that only gave a JavascriptException. Apparently ActiveXObject is an unknown type.  

Jan 3, 2011 at 2:40 PM

Although I have not tried this, it should be possible for you to create a COM interop assembly (for the component Scripting.FileSystemObject in your example) which creates .NET Runtime Callable Wrappers which should be able to be instantiated from within the Jint runtime's .NET type support.



Jan 3, 2011 at 6:12 PM

Yes I think so too. That would not be my prefered way of doing it since the end user of the program, the person doing the actual scripting, doesn't really know any .NET at all. I would have preferred to be able to provide a scripting synatx equivalent to the one already known and used. Still apart from that Jint seems to do everything I need. 

Jan 5, 2011 at 1:14 PM

I think 'ActiveXObject' is a built-in object provided by Microsoft Active Scripting (which is what the 'old' vbscript and jscript are based on). ActiveXObject is not part of ECMAScript or anything like that. To get this functionality, you would have to provide an implementation which can be done using Jint and then the javascript would look exactly like you want (i.e. new ActiveXObject('<progId>')).

System.Activator.CreateComInstanceFrom() and Jint.Native.JsGlobal.WrapClr() are probably what you need to implement the constructor.


Jan 5, 2011 at 1:18 PM

True. Good point. I'll do that.

Thanks for your input.