How to automate script using c#

Howdy guys!
I am looking at automating a process that launches rhino, does a bunch of commands using a plugin I’ve designed, then it’ll close rhino
I have the plugin correctly working if I manually run the process, but I’m struggling to get a grasp on how to launch rhino, and then run said plugin
Is there a basic template I could use that achieves this? Or is there a workaround that could achieve this?
It needs to be completely automated, as Its basically being done overnight on multiple files, so it can’t be babied through
Opening rhino is no issue but I don’t understand how the c# is meant to see that rhino has loaded, and then to send a command into the rhino command line

check the follow starting-points:

Rhino inside

legacy COM Interface

not recommended
see this topic

rhino only

on the windows side, you can stay in one rhino instance and open / close documents via rhinocommon.
so you will have one command in your plug-in
“start my batch process”

events

also check the power of RhinoDoc Events
and RhinoApp Events

kind regards - tom

You can also write a .bat file that starts Rhino with /runscript flag. If you need multiple commands you can use the _RunScript command to group them, or even _RunPythonScript if you “speak” Python :snake:

See Rhino - Running Rhino from the Command Line for reference

I would agree with @Tom_P that opening and closing a document inside Rhino is probably a better approach. Opening and closing Rhino is slow and probably unnecessary. For example you can use this to Open a new RhinoDoc:

https://developer.rhino3d.com/api/rhinocommon/rhino.rhinodoc/open