コード例 #1
0
        public static void runOnBatch(string[] lines, string dir = null, CriticalSection paralleller = null)
        {
            using (WorkingDir wd = new WorkingDir())
            {
                string batch = wd.makePath() + ".bat";

                File.WriteAllLines(batch, lines, StringTools.ENCODING_SJIS);

                if (dir == null)
                {
                    dir = wd.makePath();
                    Directory.CreateDirectory(dir);
                }

                {
                    ProcessStartInfo psi = new ProcessStartInfo();

                    psi.FileName         = "cmd.exe";
                    psi.Arguments        = "/C " + batch;
                    psi.CreateNoWindow   = true;
                    psi.UseShellExecute  = false;
                    psi.WorkingDirectory = dir;

                    if (paralleller == null)
                    {
                        run(psi);
                    }
                    else
                    {
                        using (paralleller.parallel())
                        {
                            run(psi);
                        }
                    }
                }
            }
        }
コード例 #2
0
 public static void runOnBatch(string line, string dir = null, CriticalSection paralleller = null)
 {
     runOnBatch(new string[] { line }, dir, paralleller);
 }