, expecting the program to use the new console for its input and output.

Even a simple program crashes after it has output something to the window. Setting the output handle to NULL stops it from crashing, but the console turns into an interactive shell after the program has finished, and I don't want that.

Is there any simple way to get this to work, and if not, what is the correct way?

, expecting the program to use the new console for its input and output.

Even a simple program crashes after it has output something to the window. Setting the output handle to NULL stops it from crashing, but the console turns into an interactive shell after the program has finished, and I don't want that.

Is there any simple way to get this to work, and if not, what is the correct way?

Thanks

Now you have tried

Execute (program,con,con) and
Execute (program,con,0)

Don't you think there is at least one more combination to try?

And don't you think that reading the autodocs is also an option to answer such a question?

The docs clearly say that it is not allowed to set both handles to the same file.

You can append "\nEndCLI\n" to the end of your command line, then Execute will return when the command is executed. You might want to prepend "FailAt 21" to the command line so that it does not exit to the shell if something goes wrong.