ProcessUtil.cs 933 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Diagnostics;
  3. using UnityEditor;
  4. using UnityEngine;
  5. namespace GFGEditor
  6. {
  7. public class ProcessUtil
  8. {
  9. public static void ExcuteBat(string targetDir, string fileName)
  10. {
  11. Process proc = null;
  12. try
  13. {
  14. targetDir = string.Format(@targetDir);//this is where mybatch.bat lies
  15. proc = new Process();
  16. proc.StartInfo.WorkingDirectory = targetDir;
  17. proc.StartInfo.FileName = fileName;
  18. //proc.StartInfo.Arguments = string.Format("10");//this is argument
  19. proc.StartInfo.CreateNoWindow = false;
  20. proc.Start();
  21. proc.WaitForExit();
  22. }
  23. catch (Exception ex)
  24. {
  25. UnityEngine.Debug.LogFormat("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
  26. }
  27. }
  28. }
  29. }