Command Prompt control

  • Thread starter Thread starter Stephen Woolhead
  • Start date Start date
S

Stephen Woolhead

Anyone know where I can get a command prompt control? Something like the
command window in visual studion that I can add my own commands?

Thanks

Stephen.
 
I don't know of a command prompt control, but you can simulate the same kind
of thing using Process class. I happen to have a class that allows you to
simulate command line. Here it is.

public class ExecutableLauncher
{
public static string Run(string exeName, string argLine)
{
StreamReader outputStream = StreamReader.Null;
string output = "";

try
{
Process newProcess = new Process();
newProcess.StartInfo.FileName = exeName;
newProcess.StartInfo.Arguments = argLine;
newProcess.StartInfo.UseShellExecute = false;
newProcess.StartInfo.CreateNoWindow = true;
newProcess.StartInfo.RedirectStandardOutput = true;
newProcess.Start();

outputStream = newProcess.StandardOutput;
output = outputStream.ReadToEnd();
newProcess.WaitForExit();
}
catch
{
throw;
}
finally
{
outputStream.Close();
}

return "\t" + output;

} // internal static string Run(string exeName, string argLine)
} // public class ExecutableLauncher

============================
Hayato Iriumi ([email protected])
Blog: http://www.vbaspcoder.com
 
Back
Top