views:

158

answers:

2

I want to write a script that can run on a vanilla Windows (XP or later) system and call methods in an installed (GAC'd) .NET assembly. (I need to deliver the script to other people and I don't want to assume that they have anything in particular installed (other than the the assembly in question). Can I use JavaScript (JScript) or VBScript (in conjunction with the standard Windows cscript/wscript commands) to do this somehow?

+1  A: 

I've never tried it, but I would think your best bet would be to call the .Net component via COM interop. This article should get you started.

ScottS
+2  A: 

If the class whose methods you wish to call is exposed to COM, you should be able to do something like this (VBScript):

Dim o
Set o = CreateObject("MyAssembly.MyObject")
o.MyMethod()

ScottS' answer has a good link.

Justin Swartsel
The correct syntax is `Set o = CreateObject(...)`.
Helen