slek
slek

Reputation: 309

Check if process is done in VB.Net

We have this process and we want to know if the process is done? How we'll be able to check if it is done?

Here is the code:

Process.Start(filePath & ".bat", filePath.Substring(0, filePath.LastIndexOf("\")))

thanks

Upvotes: 2

Views: 3098

Answers (1)

Markus
Markus

Reputation: 22456

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

  • 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.

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

Sample:

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

Upvotes: 4

Related Questions