c#调用.bat程序执行bat文件

 private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                //bat文件路径
                string path = "E:\\work\\06接口\\sm2Test\\sm2Test\\bin\\Debug\\speaker\\a.bat";
                Process pro = new Process();
                FileInfo file = new FileInfo(path);
                pro.StartInfo.WorkingDirectory = file.Directory.FullName;
                pro.StartInfo.FileName = path;
                pro.StartInfo.CreateNoWindow = false;
                pro.Start();
                pro.WaitForExit();
                //MessageBox.Show("bat文件执行成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("执行失败 错误原因:" + ex.Message);
            }

        }

你可能感兴趣的:(c#,visual,studio,开发语言)