I want to run an exe file by my c# code. The exe file is a console application written in c#.
The console application performs some actions which includes writing content in database and writing some files to directory.
The console application (exe file) expects some inputs from user. Like it first asks , 'Do you want to reset database ?' y for yes and n for no. again if user makes a choice then application again asks , 'do you want to reset files ?' y for yes and n for no. If user makes some choice the console application starts to get executed.
Now I want to run this exe console application by my c# code. I am trying like this
string strExePath = "exe path";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = strExePath;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
I want to know how can I provide user inputs to the console application by my c# code?
Please help me out in this. Thanks in advance.
ProcessStartInfo.Argumentsproperty... however, in your description you say that the program "asks" the user for input sequentially. That is not the same thing. It may just be a problem of terminology, but "arguments" provided to a program are input provided once, and only once, when the program is first executed.