I have a batch script that sets up some environment variables and then sets up a new cmd.exe within the currently executing cmd.exe.
Example of what the batch script looks like:
setlocal set foo=bar cmd.exe How do I start a new Process() object that calls this batch script, then is able to pipe the StandardInput into the new instance of the cmd.exe?
This is my current code that doesn't work:
ProcessStartInfo procStartInfo = new ProcessStartInfo(); procStartInfo.FileName = @"C:\path\to\test.bat"; using (Process proc = Process.Start(procStartInfo)) { proc.StandardInput.WriteLine("echo %foo%"); // InvalidOperationException }