/// <summary>
/// 启动外部程序
/// </summary>
/// <param name="cmdExe">执行文件</param>
/// <param name="cmdStr">执行参数</param>
/// <param name="cmdWait">等待完成</param>
/// <param name="cmdShow">隐藏窗口</param>
/// <returns></returns>
public static bool RunCmd2(string cmdExe, string cmdStr, bool cmdWait, bool cmdShow)
{
bool result = false;
try
{
using (Process myPro = new Process())
{
//指定启动进程是调用的应用程序和命令行参数
ProcessStartInfo psi = new ProcessStartInfo(cmdExe, cmdStr);
myPro.StartInfo = psi;
if (cmdShow == true)
{
myPro.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
myPro.Start();
if (cmdWait == true)
{
myPro.WaitForExit();
}
result = true;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());// 异常信息
}
return result;
}
C#启动外部程序
最新推荐文章于 2023-12-18 14:05:19 发布