Existing COM components are valuable resources for using in the managed code. There is almost no difference between using the COM components and managed assemblies in C# script. This is because the COM component is always accessed from the managed code through the type library assembly (which is just an ordinary assembly) prepared with Type Library Importer utility. This utility is a part of .NET Platform SDK. When the type library assembly is prepared it can be used just as any other assembly (see Using COM tutorial).
Note that importing the type library can be automated with pre-script directive ("Single-line COM access"). What practically means that by having a single line //css_... directive in the script code you can gain access to the specified COM object with no extra development cost.
|//css_pre com(WScript.Shell, swshell.dll);
static public void Main(string args)
object envType = "SYSTEM";
IWshEnvironment wshSysEnv = new WshShellClass().get_Environment(ref envType);
wshSysEnv["TEST"] = "MyDirectory";
dwImpLevel - dwImpLevel parameter of CoInitializeSecurity function (see MSDN for sdetails)
dwCapabilities - dwCapabilities parameter of CoInitializeSecurity function (see MSDN for sdetails)
Note: Currently //css_init directive has no affect if //css_host directive is used.