如何在VS中运行控制台程序后让VS自动运行一个批处理文件? 如何在VS中运行控制台程序后让VS自动运行一个批处理文件?也就是说按F5后,先运行项目程序,然后执行自定义的bat?在项目属性里的“生成后事件命令行”里写是没用的,那个是“生成后”而不是“生成并运行后"。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你想调用的地方调用Process proc = null; try { string targetDir = string.Format(@"D:\BizMap\");//this is where testChange.bat lies proc = new Process(); proc.StartInfo.WorkingDirectory = targetDir; proc.StartInfo.FileName = "testChange.bat"; proc.StartInfo.Arguments = string.Format("10");//this is argument //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()); } 谢谢回复,其实我的意思是不写代码,而是通过VS的某个设置,使当前项目生成并运行后,能运行一个自定义的批处理文件。比如当前控制台应用程序项目生成app1.exe,那么当我在VS里调试运行(按F5)后,app1.exe就运行了,我要这时候VS再帮我执行一个批处理文件或者某个exe。 调试目标改成一个bat文件bat里调用你的编译输出之后再调用别的 好像不行啊,我是vs2008,在项目属性的“调试”/启用外部程序里设置bat,结果运行后VS报“不能对bat调试必须是exe才行” process 呃,程序末尾调用这个bat不行么?要只在调试的时候运行的话if (Debugger.IsAttached){ System.Diagnostics.Process.Start(@"C:\myBatchFile.bat");} 在C#中,如何将struct转为IntPtr? C#求助! 高手请进!~C#能制作脚本吗?或者可编程界面? C#智能设备如何显示图片 怎样读取txt文件的内容并输出 从磁盘读取一个图片文件,存入picturebox,要求图片随picturebox的大小而改变。 高分 求 Windows 服务 内存大小方法,注意,是Windows 服务 DataGrid中使用排序功能的问题 急,水晶报表登陆失败问题请教! 请教一个关于打印的问题(急盼) iTextSharp.text.pdf操作pdf文件的问题 界面加载时间长
try
{
string targetDir = string.Format(@"D:\BizMap\");//this is where testChange.bat lies
proc = new Process();
proc.StartInfo.WorkingDirectory = targetDir;
proc.StartInfo.FileName = "testChange.bat";
proc.StartInfo.Arguments = string.Format("10");//this is argument
//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());
}
bat里调用你的编译输出之后再调用别的
要只在调试的时候运行的话if (Debugger.IsAttached)
{
System.Diagnostics.Process.Start(@"C:\myBatchFile.bat");
}