private void RunProcess(String executable, String args,Boolean output)
{
#region
String line = String.Empty;
proc=new Process();
try
{
proc.StartInfo.FileName = executable;
proc.StartInfo.Arguments = args;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = output;
proc.StartInfo.RedirectStandardError = output;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
catch(Exception ex)
{
ex.ToString();
}
finally
{
proc = null;
}
#endregion
}
说明:{
#region
String line = String.Empty;
proc=new Process();
try
{
proc.StartInfo.FileName = executable;
proc.StartInfo.Arguments = args;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = output;
proc.StartInfo.RedirectStandardError = output;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
catch(Exception ex)
{
ex.ToString();
}
finally
{
proc = null;
}
#endregion
}
executable:控制台程序的exe文件所在路径和xxx.exe
args:运行参数
output:true