C#程序调用bat批处理文件

         try
            {
                //bat文件路径
                string path = "D:\\BC\\Tool\\1.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#)