How to work with type library

You can use the functions:LoadTypeLib and LoadRegTypeLib

Adds a type library to the name space for the script. This is similar to the #include directive in C/C++. It allows a set of predefined items such as enumerated type, ... to be added to the run-time environment available to the script.

Here's an example that uses constants from type library:
// For JScript syntax: typelib.w_js
// System.LoadTypeLib("C:\\my.tlb");
// Window.TextOut(1, 50, 30, " Monday " + Monday);

// I can use the "Microsoft Scripting Runtime" type library
System.LoadRegTypeLib("{420B2830-E718-11CF-893D-00A0C9054228}");
Window.TextOut(1, 50, 50, " CDRom " + CDRom);
Window.UpdateWindow();
' For VBScript syntax: typelib.w_vbs
' System.LoadTypeLib("C:\\my.tlb")
' Window.TextOut 1, 50, 30, " Monday " & Monday

'I can use the "Microsoft Scripting Runtime" type library
System.LoadRegTypeLib("{420B2830-E718-11CF-893D-00A0C9054228}")
Window.TextOut 1, 50, 50, " CDRom " & CDRom
Window.UpdateWindow
You can make the type library.
  1. You must get the MIDL compiler. As example: midl.exe is part of the VC++, Microsoft Platform SDK ...
  2. Create the IDL file my.idl:
    [uuid(2A8DB469-0702-4e83-AA21-85DFF695C669), 
     helpstring("My constants 2.0 Type Library"), 
     version(2.0)] 
    library MyConst
    {
     typedef enum {Monday=2, Tuesday=100, Wednesday} _random1;
    }; 
    
    You must change the uuid, helpstring, version, typedef enum ...
  3. Compile its! midl.exe my.idl As result: my.tlb
  4. Load typelib in the script environment. You can use the constant: Monday and Tuesday.
content
The advanced scripting shell. It is not wscript.exe!
JScript and VBScript are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.