编程语言
首页 > 编程语言> > c#运行批处理文件

c#运行批处理文件

作者:互联网

 /// <summary>
        /// 代码执行
        /// </summary>
        /// <param name="batName"></param>
        public static void RunBat()
        {
            Process proc = null;
            string targetDir = "Assets/../../../../bats/";//this is where mybatch.bat lies
            try
            {
                proc = new Process();
                proc.StartInfo.WorkingDirectory = targetDir;
                proc.StartInfo.FileName = "xxx1.bat";
                proc.StartInfo.CreateNoWindow = false;
                proc.Start();
                proc.WaitForExit();
                proc.StartInfo.FileName = "xxx2.bat";
                proc.StartInfo.CreateNoWindow = false;
                proc.Start();
                proc.WaitForExit();
                proc.StartInfo.FileName = "xxx3.bat";
                proc.Start();
                proc.WaitForExit();
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError($"Exception Occurred :{ex.Message},{ex.StackTrace.ToString()}!");
            }
        }

标签:文件,bat,..,Start,c#,批处理,WaitForExit,StartInfo,proc
来源: https://blog.csdn.net/Icecoldless/article/details/122198329