C# 調用bat文件
阿新 • • 發佈:2017-08-30
trac message style vid work 實踐 using targe creat proc.StartInfo.Arguments = string.Format("20");
//proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//這裏設置DOS窗口不顯示,經實踐可行
proc.Start();
proc.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
}
引入名稱空間:
using System.Diagnostics;
Process proc = null;
try
{
string targetDir = string.Format(@"D:\BATFile\");//this is where testChange.bat lies
proc = new Process();
proc.StartInfo.WorkingDirectory = targetDir;
proc.StartInfo.FileName = "Video.bat";
//proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//這裏設置DOS窗口不顯示,經實踐可行
proc.Start();
proc.WaitForExit();
}
catch (Exception ex)
{
}
C# 調用bat文件