Monday, March 13, 2017

Extend Windows Script Host via Registration-Free COM

I like JScript , I just wish I could more with it.  Well, now you can!  There is a lot to cover here so lets get started.

First, Registration-Free COM:

A technology that allows you to access COM objects, without having to register them.  This relies on there being a manifest that can locate the COM objects. Lots more to explore here.

Second, the Microsoft.Windows.ActCtx Object:

"object references manifests and provides a way for scripting engines to access side-by-side assemblies".  

Perfect!  All we need to do is create an Assembly, A Manifest, and then we can ingest our Assembly into WSH / JScript /VBScript / SCT files, and extend the capabilities of the scripting host.

Drawbacks?  Well, for one it requires writing an assembly and manifest to disk.  I know its not all the hotness of memory resident, but still interesting. In some cases we can get around the manifest being on disk , by setting the ManifestURL property, undocumented of course, but interesting still.  

Here is an example of extending PowerShell with our Dll

Also, you can extend say JScript with this technique as well:

Well, thats all I have for now, a quick example of extending the Script Hosts on Windows by using Registration-Free COM and the Activation Context Objects (ActCtx).

I'm sure there are questions and I'll do my best to answer them.  Things I still want to do/test.  I'd like to just embed the manifest into the assembly, so I only have to drop one file to disk.  Just need to get that done.

Thats all for today. So much goodness in Registration-Free COM ;-)