At the moment I'm developing a small wrapper around CMD using ProcessStartInfo, trying to emulate the command window and adding some extra functionality that I desperately need.
This WINFORM application is a multitab app so that you can start multiple 'sessions'. Furthermore, since the content is stored in a richtextbox, I can easily copy it and more importantly search the console log.
Up till now everything seems to work fine, but when I ask for the current directory, I see the location of this app, which is fine. But when I go one directory up, it does not seem to work.
I'm pretty sure I'm doing something wrong. Could somepoint point me out what it is, what I'm doing wrong? Here is the code excerpt that deals with the execution of the code.
System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.RedirectStandardInput = true;
procStartInfo.UseShellExecute = false;
// Do not create window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(onOutputDataReceived);
proc.ErrorDataReceived += new System.Diagnostics.DataReceivedEventHandler(onErrorDataReceived);
proc.Start();
proc.StandardInput.WriteLine("/c " + cmd);
proc.StandardInput.Close();
proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();