That’s exactly what the C# script does, using RhinoDoc.CreateHeadless method and FileObj class to export to obj without cerating anything in the open Rhino doc.
The attachced gh file is a stripped down version. The original gh file exports a few things to different file formats.
I ran the script and exported an .obj out without any problems. For what it is worth, I am using Rhino 9 WIP (9.0.25315.12305, 2025-11-11). I’m also on Windows 11 (latest updates, etc.).