Invoke Program/Script from JavaScript using Custom Protocol

I need the ability to invoke either a compiled program (e.g. C++) or a Script from JavaScript where it will be possible both to pass to and receive from the Program/Script large chunks of data (more specific, a rather long JSON) whose size could exceed hundreds of KBs.

I already have a working Custome Protocol that invokes a Batch File but this option is not suitable since there are limitations to the size of data that can be conveyed to the script and the script can only return an integer value.

So far, I was unable to find any reference that would provide a clear answer to this question. The easiest solution (for me) would be to user a PowerShell script but I saw some posts stating that such script is activated from the cmd and hence would display the same limitations as a Batch script. Also, I infer from those posts that the same might happen if I use a compiled program (i.e. being activated from cmd).

I’d very much appreciate suggestions related to the above alternative approaches and, if non of them would work, a different approach that may provide a reliable solution.

NOTE: I’m not asking for code but for a feasible direction to engage into.

Thanks.