且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查过程是否在 VB.Net 中完成

更新时间:2023-02-13 15:18:07

在将 Process.Start 的返回值保存到变量后,您可以使用几个属性/方法:

There are several properties/methods you can use after you have saved the return value of Process.Start to a variable:

  • 如果您想等到进程退出,请使用 WaitForExit 方法.
  • 如果要检查进程是否仍在运行,请使用 HasExited 属性.
  • 如果在进程结束后需要退出代码,请使用 退出代码 属性.
  • If you want to wait until the Process has exited, use the WaitForExit method.
  • If you want to check whether the Process is still running, use the HasExited property.
  • If you need the exit code after the Process has ended, use the ExitCode property.

有关 Process 类及其功能的概述,请参阅此 链接.

For an overview of the Process class and its capabilities, see this link.

示例:

Dim p As Process = Process.Start(filePath & ".bat", filePath.Substring(0, filePath.LastIndexOf("\")))
p.WaitForExit()