启动批处理文件,等到关闭并在C#Winforms中做某事

发布于 2025-02-10 02:47:15 字数 92 浏览 1 评论 0原文

我正在处理C#Winforms中的一个应用程序,但我希望它从指定的目录启动批处理文件,等待直到关闭并在关闭时做某事,例如打开其他表单。

任何帮助将不胜感激。

I'm working on an application in C# Winforms but I want it to launch a batch file from a specified directory, wait until it closes and do something when closed, like opening another form.

Any help would be highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2025-02-17 02:47:15

您可以一行进行:

System.Diagnostics.Process.Start(@"c:\directory\batchfile.bat").WaitForExit();
MessageBox.Show("Batch File execution finished."); 

You can do it in one line:

System.Diagnostics.Process.Start(@"c:\directory\batchfile.bat").WaitForExit();
MessageBox.Show("Batch File execution finished."); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文