I found many coding examples on how to execute cmd.exe and execute the command, and even execute nslookup and interact, but the problem I am facing is related to the specific dos program, which, when it starts, does not stop the "output". here is some code and i will put a comment and errors i get from c #
Here's how I set it up in a more advanced way so that I can get output from the program in events
public void StartApplication(string appNameAndPath)
{
StreamReader outputStream;
Process p = new Process();
p.StartInfo.FileName = appNameAndPath;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;
p.Start();
if(advanced == true)
{
outputStream = p.StandardOutput;
DoReadOutPut();
}
else
{
while (p.StandardOutput.ReadLine() != null)
{
txt += (p.StandardOutput.ReadLine());
}
}
}
void DoReadOutput()
{
outputStream.BaseStream.BeginRead( readOutputBuffer, 0, readOutputBuffer.Length, new AsyncCallback( OnReadOutputCompleted ), null );
}
void OnReadOutputCompleted( IAsyncResult result )
{
int cbRead = outputStream.BaseStream.EndRead( result );
ProcessOutput( readOutputBuffer, cbRead );
DoReadOutput();
}
private void ProcessOutput(byte[] buffer, int cbRead)
{
string text = p.StartInfo.StandardOutputEncoding.GetString(buffer, 0, 10000);
this.Invoke((Action)delegate
{
SetTextBoxValue(text);
});
}
API GetText ReadLastLine, - ? , exe, #, while(true){Console.WriteLine("bla");} exe, exe, . dos " "