调用exe文件

来源:互联网 发布:德国拜发 软件 编辑:程序博客网 时间:2024/04/30 12:11

        protected void startExe(String para)
        {
            Process p = new System.Diagnostics.Process();

            p.StartInfo.FileName = para;//需要启动的程序名

            try
            {
                p.Start();//启动
                if (p.HasExited)//判断是否运行结束
                {
                    p.Kill();
                }
            }

            catch (Exception e)
            {
                MessageBox.Show("执行程序异常");
            }
        }