출처 : 나
public static bool ExecuteCommand(string exeFilePath, string arguments, out string result)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = exeFilePath;
processStartInfo.Arguments = arguments;
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.CreateNoWindow = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;
Process p = new Process();
p.StartInfo = processStartInfo;
try
{
p.Start();
result = p.StandardOutput.ReadToEnd();
return true;
}
catch (Exception x)
{
result = x.Message;
return false;
}
finally
{
//Wait for the process to end.
p.WaitForExit();
p.Close();
}
}