c# - 暂停执行直到批处理文件完成

标签 c# batch-file

我正在使用 Process 运行一个批处理文件。问题是我希望批处理文件完成执行,然后执行下一组行。 这是代码片段。

Process proc = new Process();
proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + sFileName+".bat";
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
Thread.Sleep(1000);
// Method which will be executed after the batch file
Method1(); 

Method1() 应该只在批处理文件完成执行时执行。

有人可以帮忙吗?

最佳答案

你可以使用这个方法:

proc.WaitForExit();

这是 docs

关于c# - 暂停执行直到批处理文件完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30023062/

相关文章:

java - 使用批处理文件启动 java 程序时隐藏控制台窗口?

c# - ASP.NET AjaxActionLink 请求中存在潜在危险的 Request.Path

c# - 从串行端口仅接收不同的值

c# - Linq-to-entities,一次查询得到结果+行数

c# - Delegate.CreateDelegate 无法绑定(bind)到静态泛型方法

c# 我如何比较两个具有匹配字母但一个有空格的字符串

windows - 如何使用 JpegTran 在使用 Windows 的目录中递归处理所有图像并覆盖它们?

batch-file - .bat 停止 windows 更新

windows - 如何使用 Windows 批处理脚本将文件独占锁定 1 分钟?

Windows cmd shell xcopy 到网络目录不起作用