'Passing new argument to current process

My program is a launcher. It launches a game with some arguments (UI, server to connect).

CurrentProcess = Process.Start(@"path/to/the/game.exe", argumentsList);

The game provides a console where those arguments are used.

I want to reuse that same process, meaning I dont want to kill it then reopen it with the new arguments.

Is it possible to pass a new argument in the ProcessStartInfo.Arguments of the CurrentProcess object while keeping the game alive ?

if (CurrentProcess != null)
{
     CurrentProcess.StartInfo.Arguments = "new arguments to use";
     CurrentProcess.Reuse(); // something like this
}


Solution 1:[1]

ProcessStartInfo is only used when the process is started. According to the documentation, "After you start the process, changing these values has no effect". It can not be used to pass arguments to the process during execution after the process has been started. There are other methods to communicate with an executing process such as named pipes, WCF, or .NET Remoting. Here is a more extensive review of different interprocess communication options.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1