You need to write the command to the
StandardInput
property of the
Process
instance:
ProcessStartInfo startInfo = new ProcessStartInfo("C:\\Users\\Nathan\\Desktop\\stim_data_receiver.exe", "NO_STIMULATOR 1000000 REMOTE");
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = false;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = false;
Process stim = Process.Start(startInfo);
stim.StandardInput.WriteLine("hello");
If you need to send input from a different method, then you'll need to store the
Process
instance in a field:
private static Process _stim;
public static void runStim()
{
...
_stim = Process.Start(startInfo);
}
public static void enterCommand()
{
if (_stim != null && !_stim.HasExited)
{
_stim.StandardInput.WriteLine("hello");
}
}