0

I have a program that executes two cmd commands. The code that I use is this:

Process proc = new Process();
proc.StartInfo.WorkingDirectory = @"C:\OpenSSL-Win64\bin";
proc.StartInfo.FileName = "CMD";
proc.StartInfo.Arguments = "/C openssl genrsa -out ProtTest.key 2048 & openssl req -new -sha256 -key ProtTest.key -out ProtTest.csr"; //if no arguments comment this line
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();

The code works fine, but when the second command is executed the cmd window just sits and waits for the user to write some values, like email address city and so on.

My question is how to transfer those parameters as well to the cmd window?

5
  • Are you wanting to allow the user to type the email and city in directly or to provide them with your application? Commented Jan 16, 2017 at 14:10
  • 1
    If you're wanting to send them from your application, you're looking at proc.StandardInput.Write(). Commented Jan 16, 2017 at 14:11
  • I want the user to write the values in to a textbox then I want to send the values to the cmd. Commented Jan 16, 2017 at 14:20
  • Is my latest answer more helpful? Commented Jan 16, 2017 at 14:32
  • 1
    Yeah it helps thanks Commented Jan 16, 2017 at 14:36

1 Answer 1

1

I think what you're looking for is:

proc.StandardInput.WriteLine(textbox1.Text);
proc.StandardInput.WriteLine(textbox2.Text);

This allows you to input your data as though you were running the application in the command window independantly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.