v0.8.0 — VBScript scripting host (run existing SolidWorks/Office VBA macros via .vbs)
Implements FR_vbscript_scripting_host.md. Adds a second script engine to run-script so .vbs files run against the same plugin globals (swApp/swDoc/xlApp/etc.) the Roslyn .csx host exposes. Same --session attach, same output capture, same exit-code mapping.
Why
SolidWorks's entire automation ecosystem is VBA. Forcing C# rewrites blocks every forum macro, every recorded macro, every shop's library from joining the combridge ecosystem. VBScript late binding also sidesteps the entire out/ref PIA quirk family the personal_rag documents — for SW automation specifically, VBScript is MORE robust than typed C# interop, not less.
Use it
' my_macro.vbs — no GetObject, no CreateObject. combridge already attached.
WScript.Echo "SolidWorks version: " & swApp.RevisionNumber
If swDoc Is Nothing Then WScript.Echo "no doc": WScript.Quit 0
WScript.Echo "Active doc: " & swDoc.GetTitlecombridge solidworks run-script my_macro.vbs -
combridge solidworks --session pid:18472 run-script my_macro.vbs -
Extension dispatch
| Extension | Engine |
|---|---|
.csx |
Roslyn C# (existing, unchanged) |
.vbs |
New IActiveScript-hosted VBScript |
.vba / .bas / .swp |
Rejected with conversion-path hint (VBA ≠ VBScript) |
Exit codes (parallel to .csx)
| Code | Meaning |
|---|---|
0 |
success (or WScript.Quit 0) |
2 |
script not found |
3 |
parse error |
4 |
runtime error (Err.Raise, division by zero, COM exception) |
5 |
host failure (e.g. VBScript removed from this Windows) |
| any other | value from WScript.Quit(N) |
Implementation highlights
- Raw
IActiveScript+IActiveScriptParse64(FR Option B). No msscript.ocx dependency; 64-bit clean. - Reflection-based globals injection. The host site enumerates the plugin's globals object's public properties and registers each as a named script item. Works equally for
SwGlobals,ExcelGlobals,WdGlobals, etc. - Honest skip lists. Value-type properties (boxed primitives/enums) and null reference properties can't go through
IActiveScriptSite::GetItemInfoas IUnknown — both are skipped with a host-side warning above script output so authors aren't mystified. - Phase detection via
OnEnterScript(notOnStateChange(CONNECTED), which fires too late — caught and fixed via live division-by-zero test). WScript.Echo/WScript.Quitshim for cscript-compat.WScript.Argumentsdeliberately deferred to keep v0.8.0 scoped (useScriptArgslike.csx).
VBScript deprecation — honest disclosure
Microsoft formally deprecated VBScript in 2024 with planned removal from a future Windows release. This host depends on the in-box vbscript.dll. When Microsoft removes it, CoCreateInstance will return REGDB_E_CLASSNOTREG and this command will exit 5 with a hint pointing at .csx. Building on a deprecated runtime is the right call here (the existing VBA corpus is too valuable to leave unintegrated while we still can), but consumers should know they're investing in a runtime with a known sunset.
Future engines
ActiveScriptInterop.cs declares CLSIDs for both VBScript and JScript. Adding a JScript host is a one-line extension dispatcher + CLSID swap. PowerShell would be a different hosting story (Runspace, not IActiveScript) — future FR.
See CHANGELOG.md v0.8.0 entry for full implementation detail.