Aleksandras Dzierkac
Aleksandras Dzierkac

Reputation: 27

executing cmd command with parameters

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?

Upvotes: 0

Views: 81

Answers (1)

ScottishTapWater
ScottishTapWater

Reputation: 4776

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.

Upvotes: 1

Related Questions