troubleshooting Question

C# ProcessStart - How to automatically press the Y key

Avatar of JElster
JElsterFlag for United States of America asked on
21 Comments1 Solution8228 ViewsLast Modified:
Hi.. I'm using ProcessStart to automatically run an external process. I need to press the Y key after about a second to continue the process.  The process runs in DOS and I need to 'Accept' a message.  How can I press the Y key automatically here is my existing code.  thanks

  ProcessStartInfo _psi = new ProcessStartInfo("pgp.exe");
                _psi.WorkingDirectory = "C:\";
                _psi.RedirectStandardInput = true;
                _psi.RedirectStandardOutput = true;
                _psi.RedirectStandardError = true;

                _psi.CreateNoWindow = false;

                 _psi.Arguments = " -e  test.txt  public.asc  myEmail +force  ";

                 System.Diagnostics.Process proc = System.Diagnostics.Process.Start(_psi);

                 System.IO.StreamReader output = proc.StandardOutput;

                 // Attach the in for writing
                 System.IO.StreamWriter sIn = proc.StandardInput;

                 // Write each line of the batch file to standard input
                 while (output.Peek() != -1)
                               /// Need to press the enter key after the message in dos window

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros