欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#中執(zhí)行批處理文件(*.bat)的方法代碼

 更新時(shí)間:2013年03月03日 17:09:57   作者:  
本文介紹一下在C#中執(zhí)行批處理文件(*.bat)的方法。

復(fù)制代碼 代碼如下:

static void Main(string[] args)
{
    Process proc = null;
    try
    {               
        string targetDir = string.Format(@"D:\adapters\setup");//this is where mybatch.bat lies
        proc = new Process();
        proc.StartInfo.WorkingDirectory = targetDir;
        proc.StartInfo.FileName = "mybatch.bat";
        proc.StartInfo.Arguments = string.Format("10");//this is argument
        proc.StartInfo.CreateNoWindow = false;
        proc.Start();
        proc.WaitForExit();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Exception Occurred :{0},{1}", ex.Message,ex.StackTrace.ToString());
    }
}

如果要運(yùn)行時(shí)隱藏dos窗口,需使用下面的代碼

復(fù)制代碼 代碼如下:

proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;

相關(guān)文章

最新評(píng)論