Closed AZProductions closed 2 years ago
Fixed with an autosearcher.
string input = "git -h"
if (input.Length > 1) //Filters when the string is longer than 1 character.
{
try
{
Process process = new Process();
process.StartInfo.FileName = input.Split(" ")[0];
process.StartInfo.Arguments = input.Replace(input.Split(" ")[0], "");
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
Console.WriteLine(process.StandardOutput.ReadToEnd());
process.WaitForExit(); //Prevents the system to continue when the process is still not finished.
}
catch
{
Console.WriteLine("");
Console.WriteLine("Command '{0}' not found.", input);
Console.WriteLine("");
}
}
else
{
Console.WriteLine("");
Console.WriteLine("Command '{0}' not found.", input);
Console.WriteLine("");
}
Example: