码迷,mamicode.com
首页 > Windows程序 > 详细

C# 调用bat文件

时间:2017-08-30 16:40:16      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:stack   star   process   catch   sys   test   system   引入   orm   

引入名称空间:

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.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());
}

C# 调用bat文件

标签:stack   star   process   catch   sys   test   system   引入   orm   

原文地址:http://www.cnblogs.com/dogxuefeng/p/7453571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!